Backup naming conventions

Posted on 06/02/2016

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:

  1. YYYY-MM-DD-HH-MM-[note]

This is the format in which everything should be written:

  1. Year: four digits. For example: 2010, 2012, 2015, etc.
  2. Month: two digits, prefix with 0 if necessary. Examples: 01, 06, 11, etc.
  3. Day: two digits, prefix with 0 if necessary. Examples: 01, 04, 15, 30, etc.
  4. Hours (optional): 24-hour format, prefix with 0 if necessary. If this is a routine backup, I skip the hours and minutes.
  5. Minutes (optional): just like everything above. I usually round everything to the nearest 5 minutes.
  6. 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:

  1. 2016-01-30-16-00-files-before-migration.zip
  2. 2016-01-30-16-00-db-before-migration.zip
  3. 2016-01-30-16-30-files-after-migration.zip
  4. 2016-01-30-16-30-db-after-migration.zip

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:

  1. You can immediately tell when was the backup created just by looking at the name.

  2. 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.

  3. 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.

  4. By avoiding spaces, you automatically make the files upload-friendly, as you don't have to rename them before uploading to the server.

  5. 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.