Tuesday, August 7, 2012

Effective backups

We all know that backups are important, right? It's not if your hard drive will fail, it's when. Yet we don't all do them regularly because it's a pain in the butt, right?

Well here's a practical solution, which I use daily. You will need a copy of Nero disk burning software, and MD5 checksum software (Advanced CheckSum Verifier is perfect for this, well worth the modest price).

Here is a Windows batch file that will perform the whole backup automatically, all you need to do is load a blank DVD every day. Just copy the batch file, modify it in Notepad with your specific folder names, save it on your hard drive and schedule it to run daily (or weekly if you don't mind losing six days' work).

:: The DVD burning command-line program
set NERO="C:\Program Files\Ahead\Nero\nerocmd.exe"
:: The MD5 checksum calculator
set ACSV=C:\Program Files\Checksum Verifier\acsv.exe
:: '/p2' = checksum file in each folder, '/s+' process subfolders
set OPT=/f0 /p2 /s+
:: ------------------------------------------------
:: 1- CALCULATE CHECKSUMS of all the directories you will backup
:: '/u' = update (create) checksum files, '/o+' disable prompt for overwriting checksum files
:: Results stored in '\temp\checksum1.log'
"%acsv%" /u "C:\My First Folder\" /o+ %OPT% /a \temp\checksum1.log
"%acsv%" /u "C:\My Second Folder\" /o+ %OPT%  /a \temp\checksum2.log
"%acsv%" /u "C:\Users\John\" /o+ %OPT%  /a \temp\checksum3.log

:: ------------------------------------------------ 
 :: 2- BURN DVD (or copy to disk) ('^' splits command over many lines)
%NERO% --write --drivename D --real --iso "%DATE%_MY_BACKUP" --dvd ^
    --recursive --speed 4 --no_user_interaction  ^
     "C:\My First Folder" "C:\My Second Folder" ^
     "C:\Users\John"
:: ------------------------------------------------  
:: 3- VERIFY CHECKSUMS
%NERO% --load --drivename D
"%acsv%" /v D:\ %OPT% /a \temp\checksum4.log
:: ------------------------------------------------  
:: 4- Eject disc
%NERO% --drivename D --eject
:: ------------------------------------------------ 
:: 5- Display Checksum verification results
notepad \temp\checksum4.log
pause

Here is an explanation of the commands.

The double colon '::' at the beginning of the line makes it a comment.

The 'set' commands at the beginning create shortcuts that make the rest of the commands easier to read and edit.  When preceded and followed by '%' percent, the shortcut is replaced with the fully expanded equivalent. Substitute the drive and folders where you installed Nero and ACSV on your PC.

Step 1 calculates the checksum files on your source (original) disk. The checksum files are small files called "md5sum.lst". There will be one written in each folder. Substitute the name of your own folders in the batch file. You can list as many as you want.

The results of the checksum calculation or verification is written to a log file ('/a' parameter).

Step 2 burns your data, including the checksum files, to a CD or DVD. If you prefer to backup to a hard drive, or over the network, replace this step with one or more XCOPY commands. Change the drive letter in "--drivename D" with your own CD or DVD drive letter. The caret (or circumflex) '^' allows you to spread the command over many lines.

Replace "C:\Users\John" with the name that you sign on with.

Step 3 verifies the checksum on the destination (target) CD, DVD or hard drive. A checksum is a hash total of all the bytes in the file. Every file has a unique checksum. If there were any errors during the copying, the re-calculated checksum of the copy will be different from the original checksum. The checksum verification program won't be able to tell you where the error is, but it will catch it. If there is an error, you know your copy is bad, and you must re-run the backup. In three years of running daily backups over two DVDs, I have had one error.

The "--load" command closes the drive droor, which Nero will have ejected.

Step 4 ejects the CD or DVD, letting you know the job completed. Step 5 displays the result of the verification. You should see zero errors. Again, replace with your CD/DVD drive letter.

Save this file, call it "mybackup.bat", in a folder called "C:\batchjobs".

IMPORTANT: The folder names listed for ACSV must be followed by a backslash ('\'). The folder names for Nero MUST NOT have a trailing backslash.

To schedule the backup in Windows 7, click on Start, Control Panel, Administrative Tools. Double-click on Task Scheduler. In the menu, click on Action, Create Task. In the General tab, give the task a name, and Change User to Administrator. In the Action tab, browse to your batch file. In the Trigger tab, set the time and frequency. I run my backup at 3:00 AM.

Every morning, all you have to do is pluck the disc from the CD/DVD drive, label it, file it in a paper sleeve for the cheapest storage.

Another benefit of this solution is that the checksum files remain permanently in the backup directories. You  can run the checksum verification any time to confirm the validity of the backup, long after the original has been modified.

You can compare the CD/DVD to the original hard drive with the best utility ever designed to do this: Beyond Compare, worth many times its price.

Occasionally, the automatic Windows upgrade might mess up the job by rebooting in the middle of a backup. Not a problem: just run the batch job manually as Administrator.

The advantage of CD/DVD over cycling a set of hard drives or "thumb drives" (memory sticks), is that by the time you discover one of your files is corrupted, it might be too late, as the corrupted copy will have been spread over all available media.

BTW, I also backup to Mozy, I do a full disk backup to an external drive with Acronis, and I copy to another PC over the network.