Georged Weblog

Have you georged your mind?

June 2003 - Posts

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).

Stepping on a rake

Whammm! I did it again! How many times do I have to tell myself that Response.Redirect(string) throws an ThreadAbortException?! Here is the short version:

private void Page_Load(object sender, System.EventArgs e)
{
   try
   {
      Response.Redirect("page1.aspx");
   }
   catch
   {
      Response.Redirect("page2.aspx");
   }
}

As expected(?), browser ends up on page2.aspx. So far so good but let’s do something smart and catch the exception (ignoring decoding/encoding and other mundane stuff):

private void Page_Load(object sender, System.EventArgs e)
{
   try
   {
      Response.Redirect("page1.aspx");
   }
   catch (Exception ex)
   {
      Response.Redirect("page2.aspx?error=" + ex.ToString());
   }
}

Browser ends up on page1.aspx?! Now that’s weird. Peeking in IL source with Reflector failed to reveal any substantial differences between the two. The answer, I guess, is buried somewhere inside HttpResponse.End and Thread.Abort methods which is more than my brain can digest. Explanation, anyone?

Note to myself: never place Redirect inside try{} block but if you have to, make sure it looks like this:

private void Page_Load(object sender, System.EventArgs e)
{
   try
   {
      Response.Redirect("page1.aspx", false);
      return;
   }
   catch (Exception ex)
   {
      Response.Redirect("page2.aspx?error=" + ex.ToString());
   }
}

Posted: Jun 10 2003, 01:22 AM by georged | with 6 comment(s)
Filed under:
More Posts