Windows backups

I had a disk completely die, and my backups are not as good as they should have been. Fortunately, the data recovery people know their job.

This motivated me to figure out Windows backups. I am not sure that this is the greatest backup script, but it works for me. Here is what it does:
* creates a full backup every week (on monday)
* creates differential backups (with changes from the full backup) every day
* cycles N different backups so you have several weeks/days of backup
* copies the files from one backup media to another, MASTER to SECOND
* just requires one scheduled job
* uses a single selection of files for all backups

To set this up:
* create MASTER and SECOND directories and set the paths in the script
* use NTBackup.exe to create the file "backupList.bks" which lists what files to back up
* put the script into the MASTER directory
* schedule a job to run it every day

This script is provided as is, with no guarantee that it will work for you. Let me know if you have improvements.

set MASTER=K:\Backups
set SECOND=L:\Backups
set keepWeekly=2
set keepDaily=2

REM set test=echo to test the script
set test=

rem echo Backup# %x%

IF "%DATE:~0,3%" == "Mon" GOTO WEEKLY

ECHO Running Daily backup
for /F %%m in (%MASTER%\dailyNumber.txt) do set /a x="%%m"
set type=differential
set file=Daily%x%
set /a x="( %x% + 1) %% (%keepDaily%)"
echo %x% > %MASTER%\dailyNumber.txt

goto DONE

ECHO Running Weekly backup
for /F %%m in (%MASTER%\weeklyNumber.txt) do set /a x="%%m"
set type=normal
set file=Weekly%x%
set /a x="( %x% + 1) %% (%keepWeekly%)"
echo %x% > %MASTER%\weeklyNumber.txt


%test% ntbackup.exe backup "@%MASTER%\backupList.bks" ^
/n "%file%" /d "%DATE%" ^
/v:no /r:no /rs:no /hc:off ^
/m %type% /j "%file%" /l:s /f ^

%test% copy /Y /B "%MASTER%\%file%.bkf" ^

set local=%USERPROFILE%\Local Settings
set data=%local%\Application Data\Microsoft
move "%data%\Windows NT\NTBackup\data"\*.log ^

1 comment:

Abhinay said...

That's a cool backup script. I am Abhinay Kampasi from India. I will be joining the CS department at UT Austin this Fall. Hoping to interact with you soon.