KB

Ntbackup Managed Mode Backup Script

Version: 1.00
Modified: 22/11/2007

Batch File:

REM - Set %day% to Monday, Tuesdsay, etc.
set str=%date%
set str=%str:~0,3%
SET day=%str%
set map=mon-Monday;tue-Tuesday;wed-Wednesday;thu-Thursday;fri-Friday;sat-Saturday;sun-Sunday
call set day=%%map:*%day%-=%%
set day=%day:;=&rem.%

echo Refreshing RSM database....
rsm.exe refresh /LF"%drivename%"
sleep 30

:backup

echo Clearing existing profile log files....
del "%USERPROFILE%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\Data\*.log" /q
echo Backing up selected items....

start /wait ntbackup.exe backup "@%bks%" /n "%day" /d "%day" /v:no /r:no /rs:no /hc:on /m normal /j "%day%" /l:f /t "%day%"

echo Moving log file
cd Logs
copy "%USERPROFILE%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\Data\*.log" .\%dtt%.log
ren %dtt%.log %dtt%.txt
type %logs%\%dtt%.txt > %logs%\%dtt%.log
del %logs%\%dtt%.txt
cd ..

echo Emailing log file....
blat %emailtxt% -to %notify% -s "%emailsubject%" -attacht %logs%\%dtt%.log
blat %emailtxt% -to This email address is being protected from spambots. You need JavaScript enabled to view it. -s "%emailsubject%" -attacht %logs%\%dtt%.log
echo Ejecting tape....

rsm eject /pf"%day% - 1" /astart

goto end

:notape
blat %notapetxt% -to %notify% -s "%notapesubject%"

:end
exit

Additional Steps:
Edit section

Create a unicode text file for the email body referenced in the script.

Create a backup selections file in ntbackup, and File, Save As. You'll need to reference this file using the %bks% variable as set below.

Variables to customise:
Edit section

Get the drive name from Removable Storage - right click on My Computer, Manage, Storage, Removable Storage, Libraries.

set drivename=SONY SDT-9000 SCSI Sequential Device
set bks=D:\Scripts\Backup\Tape.bks
set logs=D:\Scripts\Backup\Logs
set notify= This email address is being protected from spambots. You need JavaScript enabled to view it.
set emailtxt=D:\Scripts\Backup\Body.txt
set emailsubject=Backup Completed
set notapetxt=D:\Scripts\Backup\Notape.txt
set notapesubject=Backup attempted - no media present