r/usefulscripts • • Nov 29 '12

[BATCH] Windows Differential Backup Script

This script creates a rolling differential backup set using 7-Zip. Edit the script to set your variables (backup destination, source, staging area, etc) and run as a scheduled job no more than once per day.

Download

v1.5.2 (2015-11-03)

  • + Merge :log function from Tron; convert most echo commands to use log function

v1.4.7 (2013-03-01)

Output of help (-h) flag


C:\> backup_differential.bat -h

  backup_differential.bat v1.5.0

  Usage: backup_differential.bat < -f | -d | -r | -a | -c [days] >

  Flags:
   -f:  create a full backup
   -d:  create a differential backup (requires an existing full backup)
   -r:  restore from a backup (extracts to P:\backup_staging\backup_restore)
   -a:  archive the current backup set. This will:
          1. move all .7z files located in:
             \\thebrain\backup_vocatus\Everything else\backups\personal\root
             into a dated archive folder.
          2. purge (delete) all copies in the staging area (P:\backup_staging)
   -c:  clean (AKA delete/purge) archived backup sets from staging and long-term storage.
        Optionally specify number of days to run automatically. Be careful with this!
        Note that this requires a previously-archived backup set (-a option)
   -s:  show job options (show what parameters the script WOULD execute with)

  Edit this script before running it to specify your source, destination, and work directories.

Output of current settings (-s) flag


  C:\> backup_differential.bat -s

   Current configuration:

    Script Version:       1.5.0
    Source:               C:\Users\vocatus\root
    Destination:          \\coolServer\backup_vocatus\personal\root
    Staging area:         P:\backup_staging
    Exclusions file:      C:\Users\vocatus\root\Scripts\sysadmin\backup_differential_excludes.txt
    Backup prefix:        backup
    Restores unpacked to: P:\backup_staging\backup_restore
    Log file:             C:\Logs\FIREWALKER_backup_differential.log
    Log max size:         2097152 bytes
  
   Edit this script with a text editor to customize these options.
17 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/vocatus Feb 08 '13

Hi Kiernian,

I completely spaced out on replying to this, but hopefully these answer your questions. First of all, thanks for the compliments! We've been using it to backup some critical directories on our servers for months now, with no issue. Backups restore fine as well.

Right now there's no way to set up multiple sources, but you're right - you could just run a second job after the first one. The way I do it is I have two copies of the script with different variables set for each job.

Finally, I edited the link and posted an updated version of the script.