cmd Scripts for Windows for doing daily, weekly, monthly and yearly backups of a specific path in multiple generations. The script uses the windows standard command line tool 'robocopy' to create the backups.
Since the comments in the scripts are in german, this documentation explains the same in english.
backup_fhw.cmd <src> <dst> <n>|m [-i] [-z [-d][-c]] <src> - Source directory. Will be backed up with all sub directories. <dst> - Destination direcotry to hold the backup. <n> - Number of generations to create for the backup. Every generation is a subdirectory of <dst>. The script reads the last created generation from the file 'generation' in <dst> and adds 1 to that number. If the new generation is greater than <n> the new generation will be changed to 1 and the subdirectory 1 of <dst> will be overwritten since this is the oldest generation. -m - Manual backup. Overwrites the last manual backup in the subdirectory 'manuell' of <dst>. -i - If not set the script stopps Services configured in file 'config.cmd' and restarts them after backup. If set the script stops no services during the backup. -z - If set the backup in <dst> will be created as a zip archive. -d - Effective only if '-z' was set. If set only the zip archive remains at <dst> after backup. -c - Effective only if '-z' was set. Creates a copy of the created zip archive to the file 'current.zip'. So the file 'current.zip' always contains the last backup.
Use the windows task sheduler for calling the the script 'backup_fhw.cmd' in the period you want.
This keeps 7 generations of the source folder.
C:\backup_fhw\backup_fhw.cmd c:\xampp f:\backup_fhw\daily 7
This keeps 4 generations of the source folder only zipped and copies the newest zip archive also to 'current.zip'.
C:\backup_fhw\backup_fhw.cmd c:\xampp f:\backup_fhw\weekly 4 -z -d -c
This overwrites the manual backup in the subdirectory 'manuell' in the destination directory.
C:\backup_fhw\backup_fhw.cmd c:\xampp f:\backup_fhw -m