Unixtrix: Backup

I back up my files remotely using rsync. For the Mac Erin and I share, on which we keep gobs of pictures, video, and the like, that’s not feasible given our limited bandwidth. Erin is good at archiving files to DVD, but it’s time consuming. So we established a quick and dirty way to keep things backed up day to day:

  1. We bought two identical external hard drives, 400GB each. Since speed isn’t that critical, we didn’t spring for anything super-fancy.
  2. I formatted the drives and named one “xtaa” and one “xtbb” so they were easy to differentiate.
  3. I created directories on each drive which correspond to the names of the locations we want to back up:
    • “Whatever” for /Volumes/Whatever/ (our “scratch drive”, used for media and other stuff)
    • “Users” for /Users/ (where user data lives in Mac-land)
    • “Applications” for /Volumes/Mac/Applications/ (not necessary, but what the heck)
  4. Then I wrote two short shell scripts (“synch-aa.sh.txt” and “synch-bb.sh”) with three rsync entries, one for each location:

    rsync --delete -av /Volumes/Mac/Users/ /Volumes/xtaa/Mac/Users/

Now backing up is down to two steps. From Erin’s account, which is an administrator, we open a shell and type:

sudo bash (then enter password)
./synch-aa.sh

The first backup took a while. Subsequent backups are quick, since rsync only backs up files which have changed (and just the differences between files, to boot). The --delete flag deletes files first, to ensure there’s room for new files (an issue if Erin is video editing).

And finally, because backup ain’t backup unless it’s off-site, I rotate the hard drives to and from another location every two or three days (and then use the other script). Not a perfect system, but definitely worth a few hundred bucks, and a nice supplement to Erin’s good work filling a firebox with DVDs.

This entry was posted in Nerdliness, Shell tricks and tagged , , , , . Bookmark the permalink.

6 Responses to Unixtrix: Backup

  1. Jeff Watkins says:

    I know this was probably fun to figure out in a sort of man-vs-machine way, but I think you should consider Time Machine any way. Since the drive is connected directly to your Mac, Time Machine would be the easiest solution. Plus it backs up even if/when you forget to.

  2. cbd says:

    As far as I could tell, TM doesn’t do what I want rotation-wise (multiple backups of the same data). Do tell if I’m wrong.

  3. cbd says:

    Hrm, or maybe I could clone the target drive… is it a mountable filesystem?

  4. Jeff Watkins says:

    It is a mountable file system, but I think the data is hidden somewhat. In addition, you can use multiple drives via slight “hacks”. Take a look at:

    http://www.macosxhints.com/article.php?story=20080105135511764&query=time%2Bmachine

    And since you have the drive connected to your Mac, you’ll get hourly backups.

  5. cbd says:

    That looks like it would work. It would be cool if TM itself had that functionality: backup to whatever of the following drives/network shares/whatever are listed…

    I suppose as a fallback I could clone the backup drive with dd, but that would be a bit time-consuming, to say the least.

  6. Jeff Watkins says:

    I agree it sounds like a good feature. I’ve filed a radar for an enhancement to Time Machine to support multiple backup drives. Maybe we’ll see this in a future version.

Comments are closed.