Taking the Bite Out of Backup

With a confusing array of backup solutions for Mac OS X, we pick out a couple of our favorites: Apple’s Backup and the open source, Perl-based psync.

Backup is the bane of anybody’s computer existence. You know it’s an integral part of data hygiene — not unlike flossing, in fact. But it’s late, you have a presentation in the morning, and you’re too busy creating data to bother finding a CD or some extra hard drive space to shove a backup set onto. Not that you’d know what and how to back up in the first place.

Many of the available software applications don’t work as advertised, are complicated when they shouldn’t be, don’t restore as one would hope during your time of need, and are often expensive to boot. Online backup always sounds like a good idea; and it is, for reasonably sized data sets, meaning not mine and probably yours.

Backup proves such a pain that you never really think about it until it’s too late — again, much like flossing.

So what’s a data hog to do?

.Mac’s Backup

Backup (http://www.mac.com/1/iTour/tour_backup.html), .Mac’s free personal backup software, has the simplicity you’ve been craving in a backup application.

It sports an intuitive iApp-style interface and an intelligent QuickPicks feature to help you identify important files and locate them on your hard drive for you rather than the hunt-and-peck of lesser backup programs. You can back up to CD or DVD, even spanning multiple CDs or DVDs should your important data be just that much. If you’re a .Mac member ($99.95 per year), you have 100 megabytes of iDisk space (upgradable up to 1 gigabyte for a fee) that can be used for remote backup. That 100 megabytes isn’t much and will be gobbled up pretty quickly if used as your primary backup space, but it’s useful for backing up your address book, keychain, Internet Explorer settings and favorites, Quicken financial data, and a few other vital files while you’re on the road.

Tip

Disappointingly, Backup doesn’t allow you to back up to an internal or external hard drive, meaning that my 20-gigabyte external FireWire simply can’t be used by this utility. Otto Moerbeek has a nice hack for running Apple’s Backup without a .Mac account (http://www.drijf.net/dototto/).

Backup is also covered in [Hack #3].

psync

Dan Kogai’s psync (http://www.dan.co.jp/cases/macosx/psync.html), part of the MacOSX::File (http://search.cpan.org/dist/MacOSX-File/) Perl module distribution is a rather nice, free, open source backup solution. It will back up Mac volumes, synchronize directories, and create bootable backups but cannot yet make an incremental backup of only changed files. It plays nicely with just about any media you throw at it, including NFS and Samba for remote backup.

psyncX

psyncX (http://sourceforge.net/projects/psyncx) is an Aqua front end to the psync command. psyncX’s Package Installer guides you gently through installation of both psyncX and the underlying psync Perl bits. It includes a handy backup scheduler (see Figure 1-9), so you can archive your data while you snooze — just so long as your computer isn’t asleep as well.

The psyncX Aqua interface

Figure 1-9. The psyncX Aqua interface

Backing up

If you forego psyncX’s GUI interface and would rather run psync from the command line or regularly out of cron [Hack #53], go ahead and start up the Terminal [Hack #48]. Run the psync command specifying a source directory to back up and a destination directory for the backup. Here I back up everything in my Documents directory to my FireWire drive:

% psync ~/Documents /Volumes/Fire

The destination directory should be on another disk or at least another partition; otherwise, it won’t do much good if the original partition or drive goes under.

To back up anything but your own home directory, you need superuser privileges [Hack #50]; after all, you can’t back up what you don’t have permission to access. Use the su command to temporarily (for this command only) become the superuser. For example, the following backs up everything on the local drive (the / directory and below) to another mounted volume, /Volumes/BackupDisk:

% sudo psync / /Volumes/BackupDisk

By the time you next back up the same source directory to the same destination directory, you may well have removed some of the original files — that project was over and you wanted to be rid of all traces of it. If you really don’t want them in your backup directory, tell psync to delete those files that exist in the destination but not in the source, using the -d switch like so:

% psync -d ~/Documents/Projects /Volumes/Fire

Testing backup

To test psync to make sure it does the right thing without actually copying any files, use the -n switch to turn on simulation mode. The psync command reports what it would have done, but does nothing otherwise.

% sudo psync -n / /Volumes/BackupDisk

Remote backup

To back up to a filesystem other than a mounted hard drive, use the -r switch to turn on remote backup mode:

% psync -r ~/Documents /Volumes/Windows_Share

Since remote filesystems do not behave in quite the same manner as a local hard drive, psync stores some extra information in a file called .psync.db .

Restoring from backup

To restore your data, simply reverse the source and destination directories — you’re only synchronizing/copying, after all. The psync command automatically turns into remote restore mode if it finds the .psync.db file in the source directory, and allows it to restore file ownership and permissions.

See Also

—brian d foy

Get Mac OS X Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.