A better backup

I’m continuing the theme of cost-saving lab tricks (see this post on the topic).  Over the summer my laptop died on me.  While putting everything back together I couldn’t find my key for the commercial synchronization software (Allway Sync) that I’d been using to backup my computer.  I could have migrated to the provided backup software in Windows 7 (or Timemachine, if I had a mac’nbook), but for some reason I have a strong mistrust of these programs.  It may be that I’m not an experienced enough user, but I want my backup files to be a human-navigable copy of my hard drive.  This way if my laptop is lost or suddenly fails I can plug the drive into any computer and instantly access what I need.  If my laptop fails as a result of a virus it also allows me to manually rebuild the system, hopefully avoiding a re-infection.

To avoid repurchasing third party synchronization software I decided to look for a solution that relies on windows commands.  After a little searching I discovered the windows command robocopy which, when the right options are selected, does the trick (the linux/unix/os command cp should work for those systems, though I haven’t dialed in the options yet).  My laptop has two hard drives, so I run robocopy for each as such:

ROBOCOPY C:\ F:\C_backup\ /zb /xo /E /Z /V /R:2 /W:0 /MIR /tee

ROBOCOPY E:\ F:\E_backup\ /zb /xo /E /Z /V /R:2 /W:0 /MIR /tee

The backup drive, one in my office and one at home, is always F.  The command is telling the system to write everything on C (and E) to a specified directory on F.  The zb option enables “backup mode” (if access is denied a read-only copy of the file is created), xo insures that only new or modified files are copied, E copies all subfolders, Z allows a restart if the connection is lost, V enables verbose mode (so you can see what is being copied), R:2 means that two attempts will be made to copy a file, if it cannot be accessed on the first attempt, w:0 indicates that the system should wait 0 seconds for the second try, MIR removes deleted files from the backup drive, and tee directs the log output to the screen.

To make the two commands easier to execute I wrote them into a batch file.  A batch file (analogous to a shell script in the unix family of operating systems) is a text file with the extension .bat.  You can create this in notepad or the text editor of your choice, and no header (such as the #!/bin/bash for bash shell scripts) is required.  Double clicking on the .bat file instantly executes the commands in it, in the order that they appear.

This worked well for a while.  Backup.bat lived on my desktop and I’d execute it whenever I felt the need to backup (typically daily, once at office and once at home).  Robocopy is fast and not very resource intensive allowing me to continue working while it ran.  However after a bit I decided I wanted to house the file in my Start menu for easier access.  I struggled with this before learning that the Start menu really doesn’t want to host a .bat file.  Fortunately there’s an easy solution – convert the .bat to a .exe.  There are a few free converters out there, I used this one.  My new backup.exe is recognized by the Start menu and allows me to quickly, freely, and transparently backup my system whenever I want.

NOTES ON TIME: When robocopy is run for the first time it takes a while, at least overnight for the average hard drive.  Subsequent backups on my system (two hard drives totally ~ 700 gb) takes ~2 hours, depending on the number of changes, the number of files in the source directory tree, and the size of the tree.  The process can be stopped just by closing the terminal window that pops up during execution, with no ill-effects.

2740 Total Views 8 Views Today
This entry was posted in Research. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Anti Spam by WP-SpamShield