Navigation
« EasyPay in the Apple Store 2.0 app | Main | Coffee Disaster »
Thursday
Sep222011

Automatic Time Machine Switching

With the ubiquity of mobile computer and especially their dominance among Apple’s product offerings, it’s probably a very common set-up for people to use a MacBook both at home and at the office. This gives you a lot of flexibility and avoids having to maintain two installations — which can take a lot of time, depending on the amount of customization you’re applying to your machine. You bring your machine and therefore never have to sit down at an out-of-date computer.

There’s one problem though: Do you also carry along your time machine backup? Because if you don’t, and you spent a significant amount of time at either location, there will be large gaps and opportunities for failure in your backup schedule. (Yes, there’s mobile time machine but I see that as an option when you’re really on the road. A same disk backup is not truly a backup, it’s more like “Trash on steroids”.)

So what are the options? You could carry an external disk around and use that for backups. The problem with this is, though, that it takes a lot of discipline to hook it up every time you sit down in one place in order for the hourly time machine backups to happen. Part of the beauty of time machine is that, if it’s configured to back up to a network volume, you never have to do anything for it to kick in. All you need to do is enter you wifi zone.

Another reason an external disk is not ideal is the fact that it’s not redundant in itself. It’s just a single disk and single disks fail. Ideally, a time machine backup sits on a RAID-5 or some other redundant configuration – none of which is going to be portable.

In my opinion, the ideal solution to this is to have a time machine set-up at each location where you spend a significant amount of time and which you get switched to automatically on joining the respective network. When I saw the macosxhints article about using two time machine backups a few days ago, I knew that all the bits were there to set this up. However, I didn’t want to install extra tools like the article describes (MarcoPolo) and therefore I wrote a little ruby script that does everything automatically.

The script is available at github. The readme file explains most of the details but in a nutshell autotm does the following:

    • autotm looks at your system.log to determine if the last backup failed
    • if it failed, 

autotm

    will go through the list of configured servers to look for an alternative
  • if multiple servers respond to pings, autotm will pick the fastest one (your office server may be visible via a presumably slower VPN connection for example but you want to avoid backing up there from home)
  • if your last backup was successful but the server is not available anymore autotm will check for alternatives and pick the fastest one, as described above

So essentially, all you have to do is set up two (or more) time machine backups for you machine and then record their details in the config file. The LaunchDaemon will then trigger autotm every 30 minutes to check if it needs to switch time machine targets without any action required on your end.

Reader Comments (7)

So glad you decided to write this! I had been trying to talk the developer of ControlPlane (branch of MarcoPolo) into adding the automagic you added into your switching app.

I wrote the article at Mac OS X Hints and will write about your autotm at www.backuposx.co this coming week once I have tried it out.

September 25, 2011 | Unregistered CommenterAndy Boutte

<p>Glad you find it of interest, Andy! Looking forward to that article :)</p>

September 25, 2011 | Unregistered CommenterSven A. Schmidt

Thanks for resolving that issue at GitHub so fast! Heres the article:

http://backuposx.co/autotm-automatically-switching-time-machine-backup-destinations

October 4, 2011 | Unregistered CommenterAndy Boutte

This is a great piece of software -- I've been struggling with an installation of marco polo and some other associated scripts for some time to do automatic time machine disk switching and its not satisfactory. However, my setup involves an external USB hard drive at work and a networked time capsule at home. As far as I understand it, this is not currently supported by autotm? If so is there any chance of adding this functionality in the future? I would be very interested if so!

November 8, 2011 | Unregistered Commenterwannymahooots

<p>Thanks a lot for you feedback, Dan! It should be possible in principle to support backups to USB as well, the only difficulty is in testing it without setting up a USB backup myself :) Maybe we can work something out if you send me a relevant snippet from your console log. I'll get in touch via email.</p>

November 8, 2011 | Unregistered CommenterSven A. Schmidt

I am also interested in being able to use autotm with a locally attached drive. If you need any logs files let me know.

November 8, 2011 | Unregistered CommenterAndy Boutte

For reference, local backups have been implemented.

May 14, 2012 | Registered CommenterSven A. Schmidt
Comments for this entry have been disabled. Additional comments may not be added to this entry at this time.