Conventions save your time and make it easier to work with more people and more projects. I find that conventions for naming files outside of any computer-related system are rarely standardized, and can cause confusion and delays.
Backups should be automated whenever possible, but even then it's a good practice to do this manually from time to time. Scheduled backups might include only the most important parts and sometimes cannot include additional data, such as software configuration files.
The model below can be used for file and directory backups. I use it for regular documents, site backups, database exports and almost anything else. Once you understand the rules, it's very simple to always name the files correctly and avoid confusing names given in a rush.
Here's how I name all backups:
This is the format in which everything should be written:
- Year: four digits. For example: 2010, 2012, 2015, etc.
- Month: two digits, prefix with 0 if necessary. Examples: 01, 06, 11, etc.
- Day: two digits, prefix with 0 if necessary. Examples: 01, 04, 15, 30, etc.
- Hours (optional): 24-hour format, prefix with 0 if necessary. If this is a routine backup, I skip the hours and minutes.
- Minutes (optional): just like everything above. I usually round everything to the nearest 5 minutes.
- Note (optional): think of this as tags. Lowercase all letters, use dashes instead of spaces and use only letters and numbers.
Here are some examples:
Some additional guidelines:
Include hours and minutes if you expect to create multiple backups in the same day. For example: before and after upgrading the database.
If for any reason you store backups of multiple projects in the same directory (e.g. live and dev site), add project name as the prefix. Follow the same principles as for the item #6 above (lowercase, dashes instead of spaces, alphanum characters).
There are several main benefits of using this approach:
You can immediately tell when was the backup created just by looking at the name.
By writing the time from year > day, you can sort the files based on their file name and still get the exact ordering in which backups were created. This will work the same way also in terminal, without any additional commands.
By including the creation date directly in the file name, you don't have to rely on meta timestamps for determining when the file has been created. This can get overwritten in certain cases, such as when you download the backup from a server or re-package the files.
By avoiding spaces, you automatically make the files upload-friendly, as you don't have to rename them before uploading to the server.
The model is very self explanatory (except the date in some cases) and does not need much explanations. This means that other people will have no issues undestanding the way you name the backups and will be able to use the same model.