Setting Up a Pre-Backup Command that Will Automatically Manage Sets of Backup Files Saved to a Network Share

How to set up a backup retention policy for backup archives saved to a network share

Download pre_i_no_credentials.zip.

The batch file provided will allow you to set up a backup retention policy for the backup files saved to a network share. Please rename the pre_i_no_credentials.txt file to pre.bat and follow the instructions provided below to set it as a pre-backup command for your backup task.

(!) There is no need to edit the batch file provided. The target location, amount of backups and amount of backup sets that you want to keep is specified by providing the corresponding parameters (see more details below).

Setting it up

  1. Schedule a daily, weekly or monthly backup task choosing a network share as a target location for backup files. Make sure to select the "Create an incremental backup" or "Create a differential backup archive" option depending on whether you want to create incremental or differential backups.

  2. Place the batch file provided into a folder on the local disk of the backed up computer or to a network share (so that the same batch file is accessible for other machines too) and then set it as a pre-backup command in the Backup Creation Options specifying the following parameters in the 'Arguments' field dividing them by one space:

    (!) If the path to the batch file contains spaces (for example, C:\batch scripts\pre.bat) then, according to the common Windows Command Line scripting rules, you must take it into double quotes (for example, "C:\batch scripts\pre.bat"). Otherwise, the batch file will not execute as a pre-backup command.

    (!) If the path to the target network share contains spaces (for example, \\myserver\backup folder) then, according to the common Windows Command Line scripting rules, you must take it into double quotes (for example, "\\myserver\backup folder"). Otherwise, the batch file will not be able to get the access to the shared folder.

    Here is an example of the correctly configured pre-backup command:

    (!) The batch file does not contain any user credentials for accessing the target shared folder and therefore will only be able to access it if the user profile that you schedule the task to execute under has Full Control rights over the target share.

    For example:

Here is what this pre-backup command is going to do

  1. Once the amount of backups in the backup folder reaches the predefined limit, it will place the entire set of backups (set = full + a number of incremental or differential backups) to a subfolder named set1, set2, set3, etc.

  2. Once the amount of backup sets (set1, set2, set3, etc. subfolders) reaches the predefined limit, the oldest one (set1) will be deleted and the rest will be renamed in the following way set2 -> set1, set3 -> set2, etc.

    For example, if you set up a daily backup task and specify 7 and 3 for the amount of the backups in the backup set and the amount of the older backup sets that you want to keep, you will always have no more than 7 backup files in your backup folder and no more than 3 older sets of backups consisting of 7 backup files each (4 sets total, i.e. the current one + 3 older sets).

    (!) You can specify any other values than 7 and 3 (except for zeroes). For example, if you only want to keep full and no incremental or differential backups you can set the amount of backups in each set to 1 so each set only consists of one full backup.

    If you are backing up multiple machines to one central location, we suggest to utilize the following folder structure so that it is easier to point the pre-backup command to the right folder.

    \\storageserver\Backups\ (parent shared folder)

    |
    |___ \Computer1\ (subfolder)
    |
    |___ \Computer2\ (subfolder)
    |
    |___ \Computer3\ (subfolder)
    |
    ...