Automatically switching between different Time Machine disks

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

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:

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

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

cool solution. btw: do you use any harddrive encryption (filevault or something like that)?

Michel: No, I don’t use any encryption for now, maybe I should try :)

Looks like Time Machine doesn’t mount encrypted images, so that doesn’t work :(

Time Machine cannot make backups to encrypted volumes (yet). If you use FileVault for your home directory, Time Machine backs up the encrypted sparse bundle, so you have sort of an encrypted backup. The drawback is, that you can’t use Time Machine the usual way. It backs up your data only after you logged out (and the encrypted sparse bundle has
been unmounted). So no hourly backups.

I was just thinging it would be nice to write a Time Machine preferences switcher.

It would be nice to have time machine back up just my photos and documents to my Amazon S3 on weekends, and switch back to full, local backups on weekdays.

An interface like iPhoto Buddy and I think the back-end part would be pretty simple (just swapping files).

1. Direct file access by the defaults tool is deprecated and will go away (see man 1 defaults).
2. Defaults will not access TimeMachine’s defaults via the normal defaults mechanisms.
3. Thus, this fix is doomed.

@Kirk: took me a while to find what you were referring to. I think this is it:

“WARNING: The defaults command will be changed in an upcoming major release to only operate on preferences domains. General plist manipulation utilities will be folded into a different command-line program.”

Not sure what you mean by (2.) but it seems like this hint isn’t doomed, it will just get shorter:

“defaults write /Library/Preferences/ …”

will become:

“defaults write …”

Or, if all else fails, we can use the mentioned ‘different command line program’ for manual plist manipulation.

I think half the posts on will need to be updated though. :D

I’m curious about how time machine manages the effect of switching disks. As I understand it, the fsevents file only keeps a record of files that have changed since the last backup, however if that was at home, then if TM uses that file when you get to work, the work copy would be missing all the file changes backedup at home (and visa versa). Or
does switching disk trigger a full disk scan so the first backup at each location takes ages (particularly over wireless)? I assume the latter, but this seems a lot disk scanning, twice a day. Tim

I don’t know the inner details. It’s usually fast enough, so I doubt it does a full disk scan.

Hello, I’m a beginner in all this, but my boss wants me to set up his TM to backup to disks at work and at home. I would like to try your solution, but don’t understand exactly how to do it. Could you please put it in a step by step for dummies?

Much appreciated!

Would also appreciate a dummies guide as I would like to automate switching TM backup disks

Hello. I was wondering what tool TimeMachine use to write that property. If you open the lines with a HexEdit tool you can see the paths, but I’d like to know for sure so I don’t mess up anything.
I’d like to be able to choose backup location without ever having to set it in System preferences first…
Like: user type (or choose) the path, and the tool wrights it to the plist.

Also the property DestinationVolumeUUID should be set.

Got your solution through Google Search… And finally ended up using tmutil (man tmutil in terminal), which was introduced by OS X Lion.

Thanks a lot for the help, anyway !

Cool, didn’t know about tmutil. Thanks for the hint.

Do you know of any way to decode the alias into something human readable? I’m writing a script for work, and am curious as to where people are backing up to.