Georged Weblog

Have you georged your mind?

NT backup

Went to a potential client site yesterday to do a system review. My predecessor managed to convince the company’s principal that for their server they need a BackupExec. Now, that’s a > AUD$1,000 a pop and, IMHO, a waste of company’s money for the file/print server for 7 users. I don’t want to take anything away from BackupExec – it’s a great product, faster and better than built-in NT backup, does wonders in media management and great to restore individual mailboxes (God™ knows why Exchange does not allow that). But for 7 users? Ple-e-e-e-ase! I found that for small servers (my company included), NT backup works just as well.

As far as I know, the only challenges with NT backup are scheduling and reporting. Batch file takes care of the former, great command line mailer blat - of the latter. The other “cool” features: creates media name based on backup date, automatically finds latest backup report.

<rant>
Why did Microsoft remove command-line option to specify report file in 2000 and 2003 servers? Would it kill to keep it there in the same shape and form as it was in NT 4.0?
</rant>

The batch file is below. The logic is self-explanatory but feel free to drop me a line. Naturally, server name, folders and email addresses need to be changed and before batch is used, file “Daily backup.bks” needs to be created using NT backup (contains list of things to backup – take a peek inside – it’s plain text). Once everything is in place, just schedule the batch file as required.

@echo off
setlocal

Rem get date into a vairable so we can create good media name
for /F "usebackq delims=" %%i IN (`date /t`) DO set dt="%%ibackup media"

Rem Perform backup
C:\WINNT\system32\ntbackup.exe backup "@C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily backup.bks" /n %dt% /d "Daily backup set" /v:yes /r:yes /rs:no /hc:on /m normal /j "Daily backup.job" /l:s /p "4mm DDS" /um

Rem Set folder name containing backup log files
set fld=C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\

Rem This dir command will list all log files sorted by date in bare format
set fcmd=dir "%fld%*.log" /OD /A-D /B

Rem set command will set lastf variable to the last file in set, i.e. the latest one
for /F "tokens=* delims= " %%i in ('%fcmd%') do set lastf=%fld%%%i

Rem Mail latest log file to georged
c:\admin\blat.exe "%lastf%" -t georged@solutionsnet.com.au -s "Tape Backup Report" -mime -server SMTPSERVERNAME -f "backup@solutionsnet.com.au" –q

Works like a charm for me (and my clients).

Comments

Mike Scanlon said:

I just started doing some IT work while the job market warmed back up (though it might still be a long cold winter :) ). You describe above what my client (and many others before me) found out about NT Backup. Long story short, thanks for posting this handy script, after I hooked it to the windows scheduler it worked like a charm and keeps me from having to recommend an expensive backup solution for a pretty small office.
# November 21, 2003 9:19 AM

Alan said:

I was just searching for a way to figure out where NTBACKUP stores backup logs so that I could at least mail 'em, but the ability to not only do this but send the latest log file is a bonus.

Thanks man!
# June 16, 2004 12:09 PM

Michael said:

Hi,

I have being experiencing problems getting our new back solution into place with media not being recognised to unable to mount tapes etc..

I came across your script and thought i might give it a go but am a little weiry as to what to do.

you said that “Daily backup.bks” needs to be created using NT backup (contains list of things to backup) -
When you create this you are asked for media label backup label and a Schedule time for back to run.

Can you give me any pointers on how i should setup the Daily backup.bks file.

Could you also be so kind as to tell what i need to do with the batch file.

Really sorry for these questions.

Thanks
Mike
# July 27, 2004 9:52 AM

TrackBack said:

# July 27, 2004 5:20 PM

George Doubinski said:

Michael,
I gather you're using a wizard to create a backup set. Instead, try starting backup program, selecting files for backup and then clicking File->Save As (or similar).

Batch file is meant to be scheduled using Windows task scheduler instead of built-in backup scheduling abilities (it also uses Windows scheduler but that's not important).

Hope it helps
Thanks
Georged
# July 28, 2004 8:07 AM

Harinezumi said:

Great job, georged!

I have just added automatic deletion of backups older than 30 days using windows command FORFILES:

forfiles /p d:\backups\ /c "cmd /c del @file" /d -30

Also in blat I have changed

-f %COMPUTERNAME%@domain in order to receive email from the specific server I backup.

# April 14, 2008 2:42 AM

Andy Davis said:

Hi I've just tried this script on two servers on the first it runs fine and I get a new media name on the second I get an error

NtBackup Error: Usage specify a new media name for the command line option /n which is defined as per your script as /n %dt% this variable being assigned on the previous line.

Any ideas anybody

# June 3, 2008 6:50 AM

Brian said:

The script kinda worked for me, but not unattended. The script was waiting for the NTBACKUP to terminate, but after the backup finished, the NTBACKUP program didn't terminate; it just goes back to the first wizard screen. So I had to click the close button to get the script to move along with the blat.

Any idea why? Is there an undocumented command-line switch to make it close after completing the backup process?

brian [at] specimenhouse [dot] com

# July 11, 2008 12:17 PM

hooher tod said:

Yes there should realize the reader to RSS my feed to RSS commentary, quite simply

# September 5, 2011 7:32 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)