Thursday, June 5, 2008

Backing up the cheap way

I was scared back into thinking about desktop backups a couple of weeks ago. As is normally the case, I purchased a new external hard drive to 'backup' my data. Then as I created more docs, archived more e-mails, etc. this disk became just the storage place for this data. To keep the desktop clean, I moved data to the external hard drive and purged it from the desktop. I know… I know… this is terrible document protection, but laziness and lack of space created this situation.


 

The external hard drive was used for some servers builds and the file table got jacked up. With the prospect of losing all this data, I went into panic mode and started using serious data recovery tools and days of different attempts to recover the file table and retrieve the docs (including 7 years of Outlook PSTs). This finally spurred me to implementing a more stable data protection methodology. For my benefit and anyone that happens across this, I will detail what this poor man's backup solution looks like.


 

The overview:

  • Use NTBackup (cuz it's free)
  • Purchase second external harddrive with sufficient space for multiple full backups of necessary files (in this case a USB 2.0 500GB HD)
  • Configure NTBackup to perform nightly backups
  • Use batch files to initiate backups and purge the previous night's backup when tonight's completes (I know there is no logic in this file to ensure a successful backup before purging last night, but it is better than nothing. This is the cheap solution and was set up in about 30 minutes.)

Note: for this example my drives are laid out as

  • C: - local internal hard drive
  • E: - 300GB external data drive
  • D: - 500GB external backup drive (dedicated to backups)


 


 

Create a backup definition file (.bks):

This file details what directories (and/or files) will be backed up. This is not the actual job. The job is created later. Here is an example of the contents of my .bks file.

"Daily Desktop backup.bks" –

C:\Documents and Settings\wrightke.MYCOMPANY\My Documents\

C:\accounts\

C:\backup of laptop\

C:\CAConfig\

C:\certs\

C:\cluster\

C:\documents\

C:\iso\

C:\lcs\

C:\lifeway\

C:\NBD\

C:\scripts\

C:\software\

C:\sysprep\

E:\


 


 

Create seven daily backup batch files:

I have seven files named by day (Sunday.bat, Monday.bat, Tuesday.bat, etc.) that define the job for that day. The file calls the backup definition file, the configurable options for ntbackup, and then after the job completes, deletes the backup file from the previous day.

For instance, Sunday.bat will run and create a new backup named Sunday.bkf. At the end of the backup, it will delete Saturday.bkf. Monday then creates Monday.bkf and deletes Sunday.bkf.

Contents of Sunday.bat –

@echo off

C:\WIN2K3\system32\ntbackup.exe backup "@C:\Documents and Settings\wrightke.MYCOMPANY\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily Desktop backup.bks" /n "Daily Desktop backup" /d "Set created 5/23/2008 at 2:00 AM" /v:yes /r:no /rs:no /hc:off /m normal /j "Daily Desktop backup" /l:s /f "D:\ntbackups\wrightke02\Sunday.bkf"

del "D:\ntbackups\wrightke02\Saturday.bkf"


 

So you can that the Monday version just changes two file names (the .bkf file references). Just make sure you are creating a new job and deleting yesterday's. If you don't get it right, you could create Monday.bkf and then immediately delete Monday.bkf. That would defeat the purpose.


 

Create seven recurring tasks in Windows Task Scheduler:

The scheduled tasks are named by day (Sunday, Monday, Tuesday, etc.). The job calls the .bat file for that day, such as Sunday.bat. The job is set up to occur weekly, on the day that corresponds with the batch file. It is scheduled for 2:00 AM as that is probably the least likely time I will be on the machine. So task "Sunday", executes Sunday.bat and runs each Sunday. I chose to set it to stop if it runs longer than 10 hours. I also chose to remove the checkmarks that talk to starting on battery power or starting while the machine is asleep. This is a desktop so those don't really apply.

I plan to check this at least once weekly for continued operation, but I have not set up any auto-notification of completion or anything. This is just my backup copy. I also have started doing a monthly flat file copy to the external hard drive as well. So I am keeping two backups more or less.


 

Note: this machine is a domain member, so I chose to run the job as the local administrator instead of with domain credentials. The local system does not expire local accounts. However, my domain account does expire every 45 days by policy. I have dealt with scheduled tasks enough to realize that expiring passwords do not work well with these tasks.


 

Final note: Some of the files addressed with this backup are Outlook PST files. If I leave Outlook open, there will be conflicts with open files. Those are some of the more 'critical' files I would like to backup. To mitigate this, I borrowed a vbscript from the internet. I have scheduled this vbscript to run daily five minutes before the daily backup kicks off. Here are the contents of the script:


 

Set objShell = CreateObject("WScript.Shell")

Set objWmi = GetObject("winmgmts:")


 


 

strWmiq = "select * from Win32_Process where name='Outlook.exe'"

Set objQResult = objWmi.Execquery(strWmiq)


 


 

For Each objProcess In objQResult

intRet = objProcess.Terminate(1)

Next