5 Rules for Working with Files
Today I was working with a client to fix their WordPress related issue on nginx based server. Upon isolating the issue, I simply moved one file to a folder where I thought it should be residing, but boom! that place already had an updated and newer copy of that file and it all went down!
Yes it does seem quite noobish to do such a thing, but it did happen. The file was actually wp-config.php file residing outside the WordPress root directory (yes WordPress looks for it in one step up directory if it can't find it in the home root directory).
So here are few lessons I learnt and good practices I use (and will use more now) related to handing and working with files on servers and in projects.
1. Always check inside the folder before sending a file to it
As explained in example above, always check inside the folder you're sending a file to. It might contain a file with same name. So avoid getting in any such trouble.
2. Name a backup file in optimum way
I have been using this rule for quite some time now. Whenever nameing a backup file or folder or compressed file, i always follow this rule:
filename-YearMonthDate.extension
For example, if I was backing up my WordPress folder today, I would name it:
wordpress-20190114.zip
Why is this important? Well this keeps things organized and easy to read and interpret. Like if I add next backup tomorrow, it will be automatically listed below it as it will end with ...15.zip. Quite simple right?
3. Use git whenever possible
Yes I was scared of versioning too. But now all my projects are versioned. It saves you a lot in many situations.
4. Don't empty trash immediately
I have a habit to empty trash when I am concerned about the disk space. Sometimes we do delete important files and if we empty trash immediately we might lose them forever, even the ones that we deleted by mistake.
5. Always keep a backup
Never assume that your data is safe in one place. We all have lost important data due to various issues. Whenever you have important data at hand, always back it up at any convenient location as soon as possible.
Also this point includes that always work on a copy of the file. Or keep the copy of that file when working on the original one for any unforeseen situation.