SyncToy for Syncing Portable Disks
Putting together a decent backup strategy is hard. It shouldn’t be hard. Engineers ought to have eliminated the intolerable risk of data loss long ago. But it is. There’s no magical push button solution out there that will magically make all your data safe until the end of time. This is mostly because everybody has different needs in terms of protecting their data. So everybody must take the time to put together a decent backup strategy that works for them. While some strategies are better than others, any strategy is better than none and the best strategy is the one you stick with.
My own needs are (relatively) simple. As somebody who moves around a lot I’ve got a couple of portable drives that must be duly backed up everyday. Both the development laptop and the trusty netbook contain important data, from source code to lolcat pictures, that also must be protected. Just off the bat that’s at least four different disks that must be backed up. When you include other devices such as the phone and the linux box hiding somewhere under the desk things get a bit more tricky, as now we’re up to four devices and at least two portable disks. (This ongoing explosion of different devices and portable storage that consumers are exposed to ensures that the backup problem is in fact getting worse, not better, as time goes on.)
But we must bravely muddle through.
The first challenge is the notoriously fragile portable disks. Ideally, they should be periodically synchronized with the more durable, less mobile disks. Synchronized is a technical term in the world of data integrity that implies two-way synchronization between two data sources. That is, both data sources can change indpendently of the other and when the big sync moment arrives changes must be propagated in both directions. As any veteran of the data integrity fight will tell you again and again (if you let him): synchronization is not the same as backing up data. Indeed they are kind of polar opposites: one involves making a durable read-only copy of data on another device and the other involves writing changes to and from the other device so that it’s exactly like the source. Anybody who employs synchronization as a backup strategy is flirting with disaster. But synchronization does have its benefits, particularly the flexibility to edit either data source. This means if a disk is ever forgotten at home or temporarily misplaced one can continue editing the local copy of the data and just sync up later. Synchronization can introduce some problems but, if you synch up early and often it’s generally a painless thing.
If you’re on Windows a decent, and free, file synchronization application is Microsoft SyncToy. It’s fast, easy to use, and the 2.x resolves all of the major issues in 1.x such as the inability to propagate deletions and the ability to detect drive-letter changes. Synctoy also never actually deletes files in place it just copies them to the
Recycle Bin — so if you ever screw up a sync you only need to endure a moment of blind panic before you scramble to the
Recycle Bin and retrieve your precious data. Setting up a sync job between a portable disk and a directory on the local hard disk is easy to do, and, once done, you can rest easy should your external disk ever bite the big one.
Of course setting up and running the inital sync job is just the first step. The next step is automating it so that the data stays in sync. This is a bit more tricky. SyncToy can be automated using the Windows Task Manager but, when working with a portable disk this isn’t the ideal solution. Running the sync job every night isn’t going to do much if the disk is sitting in your bag or on your nightstand. Instead we can throw a
syncme.bat script into the root of the portable disk that will launch the appropriate SyncToy job.
rem Synchronize this disk with the local disk
"C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -R "camelot.sync"
(You’ll want to fill in your own job name in the above script.)
From there it’s up to you to run the
syncme.bat script each time you plug the portable disk into a computer, before you do anything else. This is a good habit to have and, as a software developer used to updating my local copy of the source code first thing, before anything else, it’s one I already possess. But if even this strikes you as too much of a burden you might look into the Windows AutoRun feature to launch the sync script as soon as you plug the disk in. This won’t work for me as I don’t want to sync the portable disk with every computer I use (such as the work laptop), mainly just the dev laptop and the trusty netbook.