Simple Windows Batch File Scheduled Backups

Here are a few Windows batch scripts that I wrote to use for scheduled backups. Each is only a few lines long, and does everything that most people will ever need, including zipped, encrypted, and simple folder backups. To use them, simply edit the paths, save the contents to a batch file (.bat extension), and use the Scheduled Task Manager to run the script at an interval of your choice.

To run regular folder backups, simply replace all instances of PATH_TO_YOUR_BACKUP_FOLDER with the path to your backup folder. For example, if your folder backups are saved to a folder called Backup in your D: drive, then replace PATH_TO_YOUR_BACKUP_FOLDER with D:\Backup. Lastly, change PATH_TO_FOLDER_YOU_WANT_TO_BACK_UP to the path of the folder you want to back up. For example, if you want to back up the folder Work on the root of your C: drive, replace PATH_TO_FOLDER_YOU_WANT_TO_BACK_UP with C:\Work.

To run zipped backups, you’ll need this file: zip.exe. Simply place it in a folder (I put it along with the batch files in a folder under Application Data), and change LOCATION_OF_ZIP.EXE to the path of the folder it’s in. For example, if zip.exe is saved in the root of your drive, replace LOCATION_OF_ZIP.EXE with C:\. Next, replace PATH_TO_YOUR_BACKUP_ZIP_FILE with the full path (including file name) of your backup file. For example, if your backup file is called backup.exe and it’s saved in the root of your D: drive, replace PATH_TO_YOUR_BACKUP_ZIP_FILE with D:\backup.zip. Finally, change PATH_TO_FOLDER_YOU_WANT_TO_BACK_UP to the path of the folder you want to back up. For example, if you want to back up the folder Work on the root of your C: drive, replace PATH_TO_FOLDER_YOU_WANT_TO_BACK_UP with C:\Work. To set a password, replace PASSWORD with a password of your choice. If you don’t want one, simply remove the word PASSWORD and the -P before it.

Regular Folder Backups:

1
2
3
4
verify on
rmdir /s /q "PATH_TO_YOUR_BACKUP_FOLDER"
mkdir "PATH_TO_YOUR_BACKUP_FOLDER"
xcopy /a /e /c /f /h /k "PATH_TO_FOLDER_YOU_WANT_TO_BACK_UP" "PATH_TO_YOUR_BACKUP_FOLDER"

Zipped Backups:

1
2
3
DEL /F /Q "PATH_TO_YOUR_BACKUP_ZIP_FILE"
CHDIR "LOCATION_OF_ZIP.EXE"
zip.exe -r -q -S -J -9 -P PASSWORD "PATH_TO_YOUR_BACKUP_ZIP_FILE" "PATH_TO_FOLDER_YOU_WANT_TO_BACK_UP"

Leave a Reply

Your email address will not be published. Required fields are marked *