Automatically switching between different Time Machine disks

  • Christian Stocker

After having finally switched to Leopard during my paternity leave (thanks again Liip for that :)) I started using Time Machine for my backup needs. Since I had an almost-always running Popcorn Hour with some spare space, the wish to use that device was kinda obvious. While not officially supported by Apple (for whatever reasons) setting it up on the samba share was pretty easy and it works pretty flawless since then.

Back at work I of course didn't want to miss the hourly backups anymore and needed a solution there too. So I did the same with a disk attached to our airport. Worked equally flawless and since Time Machine seems to handle different and changing backup disks correctly all I had to do was to switch the Time Machine disk every morning and evening. I now have two full backups of my disk, one at home and one at the office, geographically separated by approx. 2 kilometers, which should be enough for most possible disasters. And if that's not enough, then I'm not sure if I care about my backups anymore :)

But the switching every day between the two disks was cumbersome and easily forgotten, so I wanted to automate that. With some googling I found out, that the destination disk was written in the ” /Library/Preferences/ BackupAlias” property and could be read with

defaults read /Library/Preferences/ BackupAlias

This gives you a rather long string starting with something like <00000000 014e0002 …. That's what you need for later. And for both disks.

Next I wrote two little shell scripts, looking like this:

defaults write /Library/Preferences/ BackupAlias '<00000000 014e0002 ....>'

and started them, when needed. No more half a dozen mouse-clicks and typing in that password every time, just calling that script was enough, but still not perfect. Jiayong Ou to the rescue, which made me aware of the context-and-location-aware and free application MarcoPolo. A little bit of configuring and I have now a fully automated backup solution at home and at the office. I additionally added the line

/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper -auto &

to my script and a delay of 30 seconds in MarcoPolo, so that my backup started immediately when I'm online again and after the disk preference actually switched. Doesn't work always, since it's aborting a maybe running old backup, but seems not to do harm either.

That was it. A cool little application and a 2 line script is enough for making me forget about doing my backups :)

And as always: This works for me, but may completely destroy something on your side. And it's not officially supported by Apple and may therefore break with the next update. Use at your own risk

Tell us what you think