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
:WEEKLY
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
:DONE
%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 ^
"%MASTER%\%file%.bkf"
%test% copy /Y /B "%MASTER%\%file%.bkf" ^
"%SECOND%\%file%.bkf"
set local=%USERPROFILE%\Local Settings
set data=%local%\Application Data\Microsoft
move "%data%\Windows NT\NTBackup\data"\*.log ^
"%MASTER%"
1 comment:
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.
Post a Comment