Tuesday, 14 September 2004
A sample NTbackup script, with the current date/time in the filename and backup label
This script is based on the FAQ on http://www.jsiinc.com/SUBE/tip2200/rh2265.htm.
If you ever tried to automate NTbackup, you probably got it up and
running, scheduled every day or week, but then noticed over time that
the date and time labels that go on the backup file are the current
date/time of when you created the backup set. This useful shell
script provides a more intelligent solution by parsing the current date
and time and inserting them into the filename and backup label.
This makes the backups much easier to identify in the case where you
need to restore some files.
The script below makes a full backup (not differential) of the files specified in the backup set.bks. It
doesn't verify the backup, and lastly it sends a copy of the backup
file to another computer (just in case), that's what the last 3
lines are for. You can obviously remove this step if you don't
If you don't fully understand all the parameters of the NTbackup.exe... command, it's explained well here.
Save the following text as a .cmd file and add it is a scheduled task in Windows.
@for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do @set dt=%%i-%%j-%%k-%%l
Tuesday, 14 September 2004 11:18:09 (GMT Daylight Time, UTC+01:00) Windows Server
@for /f "Tokens=1" %%i in ('time /t') do @set tm=-%%i
@echo Copying backup set: %dtt%.
@echo Please wait...
@C:\WINDOWS\system32\ntbackup.exe backup "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\backup set.bks" /a /d "Backup %dtt%" /v:no /r:no /rs:no /hc:off /m normal /j "%dtt%" /l:s /f "G:\Auto Backups\Backup %dtt%.bkf"
@echo Sending backup file to Server2. Please wait...
@xcopy "@G:\Auto Backups\Backup %dtt%.bkf" "@\\Server2\Backup_Copy" /Y