Darwinweb

Making Backups on Mac OS X

March 4, 2006     

So, due to a little problem with my PowerBook I am forced to backup my hard drive not only so that I can continue working while I send it in to Apple, but also not to depend on the kindness of Apple techs to preserve my precious data.

I ran out and bought a 160GB USB 2.0 drive then set about the backup the old fashioned way… dragging my home folder to the new drive. It takes a minute or two to count up the 50GB of files then begins to copy. Unfortunately after a minute the copy fails due to an unknown inability to copy a file. There’s no obvious reason, and the error message gives absolutely no information. Okay. What am I doing using the Finder to backup 50 gigabytes of files anyway? This is OS X, we’ve got BSD under the hood.

My goals were simple:

  1. File modification times should be preserved.
  2. If any part of the copy fails, the rest should continue.
  3. I need to know exactly what failed if it does.
  4. I don’t want any locked files, they are a pain.

The solution is even simpler:

  1. Unlock all files using sudo chflags -R nouchg ~
  2. Copy directory recursive using preserve flag cp -Rp ~ target_directory 2>copy_errors.txt
  3. Monitor errors in another terminal tail -f copy_errors.txt
  4. Monitor progress in a finder window (thanks for Tiger’s Finder’s responsiveness to file changes at the kernel level).

The nice thing about this solution is it just goes. Finder copying and deleting is so interactive, you can’t start it and leave. I’m also hoping that this solution will play nice with the computer spontaneously sleeping. The only question is will the USB drive freak out.

Yes, in the future I want to have all my critical data rsynced to offsite backups, but in the meantime this will have to do.