Using the “date format” to manage the structure of backup archives in APBackup

When saving a backup archive to the primary or additional folder, APBackup can name it according to the current date. To enable this option, use the “Date format” field. This field is a date/time mask and its value is calculated at the time a backup copy is created.

For instance, if this field has the "MMDDYYYY" format, it will turn into"06162009" if the backup process is started on June 16, 2009
 Backup archive settings
When saving an archive, APBackup first creates the main archive file and then, if additional folders have been specified, copies the archive there (up to 3 local folders and 1 remote folder on an FTP server are supported). You can also configure individual naming parameters and the archive depth for each additional folder.
The archive depth parameter defines how APBackup deals with old archives. For instance, if the archive depth is 3 files, it means that APBackup will only leave the 3 latest backups after completing each backup task. You will also be able to set the depth in days and months – in this case, the program will only leave archives no older than 3 days, for example.
The value of the “date format” field can be selected from the dropdown list or entered manually. The following macros are supported:

  • c – Displays the date in the ShortDateFormat format and time in the LongTimeFormat format
  • d – the day of the month without the leading zero (1-31).
  • dd – the day of the month with a leading zero (01-31).
  • ddd – the day of the week according to local settings (Sun-Sat)
  • dddd – the complete day of the week (Sunday-Saturday)
  • ddddd – the date only (without time) in the ShortDateFormat format
  • dddddd – the date only (without time) in the LongDateFormat format
  • m – the month without a leading zero (1-12). If m follows h or hh, minutes are displayed instead of months.
  • mm – the month with a leading zero (1-12). ). If mm follows h or hh, minutes are displayed instead of months.
  • mmm – the short name of the month according to local settings (Jan-Dec)
  • mmmm – the full name of the month according to local settings (January-December)
  • yy – year as two digits (00-99).
  • yyyy – year as four digits (0000-9999).
  • h – the hour without a leading zero (0-23).
  • hh – the hour with a leading zero (00-23).
  • n – minutes without a leading zero (0-59).
  • nn – minutes with a leading zero (00-59).
  • s – seconds without a leading zero (0-59).
  • ss – seconds with a leading zero (00-59).
  • t – time only in the short format.
  • tt – time only in the full format.
  • %dw – the number of the day of the week
  • %dy – the number of the day of the year
  • %wy – the number of the week of the year
  • %wm – the number of the week of the month

Below are some examples of the use of the date format for organizing the structure of backup copies in an archive.

The current archive + monthly archives.

We need to save the current daily backup with a depth of 4 days and save monthly backups with a 12-month depth in a separate folder.
This can be accomplished using a single task only. An example of such task configuration is shown in the figure below.
In this case, we need to configure the main archive to have the “YYYYMMDD” date format and the depth of 4 days. We will also need to set up an additional folder for monthly backups with the “YYYYMM” date format and the depth of 12 files. It’s a better idea to save backups to different folders. If the main and secondary archives are saved to the same folder, you should set different prefixes for these archives, as the program will delete the files with the current prefix according to the backup depth parameter while cleaning up files after each backup.
Note the additional folder and the “YYYYMM” time format – that is, the name of the archive will be the same every day, since the name mask will depend on the month and year only. Therefore, every new backup saved to the additional folder will overwrite the previous day’s backup file. To avoid this, enable the “Do not overwrite if archive exists” option. If the option is enabled and the program detects the same file in the additional folder, APBackup will not copy the file. So when the backup is made for the first time in a month, the program will create a backup archive in the additional folder (for example, on June 2, 2009, it will create an archive called 200906) and will not copy new archives to this folder until the end of the month.
As the result, we will get 4 most recent daily backups and 12 backups made at the beginning of each month.

Sorting archives in a folder tree according to the date.

For instance, users copy different files to a certain folder. At the end of the day, you want to empty this category and back up the copied files – and it’s necessary that the folder structure in the backup archive is preserved to make searching for files easier. For example, Backup\2009\6\17\bak.zip (however, just as in the previous example, the task mode (backup or copy) is absolutely unnecessary).
To do that, just set the “backup prefix”value to “Backup” and the “date format” value to “YYYY\MM\DD\bak”. To delete the source files, check the “Delete files after archiving” option on the “Sources” tab.
Now APBackup will create the necessary folder structure and copy the backup archive according to the current date daily when the backup task is started.
Please note that “bak”, our archive file, does not contain the characters allowed in macros. This is done to prevent changes in the archive name, as it’s specified in the “Date format” field.
In this case, the archive depth parameter is taken into account and can be set to 12 months, for example.