Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.7: Using two Time Machine backups System 10.7
Rotating Time Machine backups has never been easier as of 10.7. Apple included in Lion a command-line interface for Time Machine which makes it completely scriptable. For the complete details on the command-line interface take a look at the man page for tmutil.

I use two Time Machine backups (see my backup strategy below for my complete backup solution) one at home and one at work. Using MarcoPolo you can set triggers and actions to automatically switch your Time Machine destination.

At home, and at work, I have 10.7 Server setup running the Time Machine service. Using MarcoPolo my laptop can determine its location, work or home, and set the IP address for my server appropriately. The following are the details on how to set this up for a Time Machine destination of an AFP share point. With small changes, this will also work for a Time Machine destination of an external hard drive.

Note: To alter these instructions to use a local external hard drive, change the following tmutil commands to this format:

tmutil setdestination mount_point

where mount_point is the path to your external hard drive.

Time Machine Setup

First we need to create two scripts. I have stored mine in /usr/local/bin. I used the nano editor in Terminal to create the scripts; you could also do this with BBEdit or TextWrangler if you're more comfortable with those editors. The two scripts will use the tmutil command to switch the destination. To create your first script enter this command into Terminal:

sudo nano /usr/local/bin/switchtimemachinehome.sh

Paste the following into the nano editor:
#!/bin/bash
#This will change your Time Machine setting the backup to your home server
sleep 5
tmutil setdestination afp://username:password@192.168.1.3/Backups
sleep 5
tmutil startbackup
The important line here is the tmutil command which is new as of 10.7 Lion. You will have to change the username, password, IP address, and AFP share point name to match your specifics for your home setup. Once you have those altered press Control+o to save the changes and then Control+x to exit nano. Next we need to create the second script:

sudo nano /usr/local/bin/switchtimemachinework.sh

Paste the following into the nano editor:
#!/bin/bash
#This will change your Time Machine setting sot backup to your work server
sleep 5
tmutil setdestination afp://username:password@192.168.1.7/Backups
sleep 5
tmutil startbackup
Once again save the changes for your script and quit nano. Now we will make these scripts executable with the following commands:

sudo chmod +x /usr/local/bin/switchtimemachinework.sh
sudo chmod +x /usr/local/bin/switchtimemachinehome.sh


You can test that these work by issuing this command:

sudo /usr/local/bin/switchtimemachinework.sh

or

sudo /usr/local/bin/switchtimemachinehome.sh

In System Preferences » Time Machine you should now see that your destination has changed.

MarcoPolo Setup

MarcoPolo development has stopped but it is currently working for me in 10.7.1. Once you have MarcoPolo downloaded and installed you will need to setup at a minimum two Contexts. I have Work and Home.

For Evidence Sources, I use WiFi which I have very high confidence in because I have never seen another WiFi network with the same MAC address as mine. For rules, you have to create one for Home and one Work (using the plus (+) button in the lower left) using the WiFi evidence. And under Actions, again using the plus (+) button, you can add a Shell Script Action for Home and Work. When you select the Shell Script Action, an open dialog box opens and you will need to select the shell script we created earlier. If you placed yours in /usr/local/bin like I did, you will not be able to browse there because /usr is an invisible directory. But you can press Command+Shift+G while the Open dialog box is open and it will allow you to type in the directory you want to browse.

Once the two actions are enabled, your Time Machine destinations should change dynamically based on your location. You can always verify what your current settings are by looking in System Preferences » Time Machine.

If you have trouble setting this up or questions please post a comment.

This post inspired me to figure out how to create rotating backups in 10.7 Lion.

[crarko adds: I haven't tested this one. There was another use for the tmutil command mentioned in this hint.]
    •    
  • Currently 3.43 / 5
  You rated: 5 / 5 (7 votes cast)
 
[17,745 views]  

10.7: Using two Time Machine backups | 14 comments | Create New Account
Click here to return to the '10.7: Using two Time Machine backups' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Using two Time Machine backups
Authored by: NaOH-Lye on Sep 13, '11 09:47:16AM
I haven't used it, but ControlPlane is a fork of MarcoPolo which is actively supported.

Link to ControlPlane Developer Site

[ Reply to This | # ]

10.7: Using two Time Machine backups
Authored by: ruedu on Sep 14, '11 01:53:22PM

I'm the "owner" of ControlPlane. ControlPlane runs very well on Snow Leopard and Lion with full support for the WiFi evidence source as well as bluetooth, both of which don't work well with MarcoPolo.

ControlPlane has the ability to enable/disable TimeMachine but not change out the disks. This is not something CP will support natively because it would then require CP to maintain state information about TimeMachine itself, beyond the scope of CP.

The demand for swapping out TM disks is a lot bigger than I would have thought so I'm considering creating a separate app that could be installed along with CP (but would be standalone of course) that CP could then talk to force disk changes. If I did this, I'd love to hear input on what the utility should be capable of beyond changing the disks.



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: installghost on Sep 15, '11 06:44:31PM

I would be very interested in a Time Machine switching application. Im not sure I understand what you mean by CP would have to monitor the state of Time Machine but it seems to me if CP could run scripts with root privileges CP could very easily switch the drive with the tmutil command.

I will gladly do what I can do to help make a Time Machine switching app.



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: ruedu on Jan 31, '12 04:07:05PM
App is now available, called Tedium - http://www.tediumapp.com/

[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: Tantali on Sep 13, '11 10:05:36AM

Is there any possibility to change the Time Machine exclusions as well?
e.g. you have 2 backup locations, but one is rather small and the other one big, so you backup only essential files on the small one and everything on the large one.



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: drudus on Sep 13, '11 02:06:33PM
Check the other hint, & use man tmutil to see the manual in the Terminal. It seems to be possible.

[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: installghost on Sep 15, '11 06:37:06PM

When using the command tmutil you have two options for setting exclusions. Either location-independent or fixed-path. See the man page for tmutil for all the details.

but a basic exclude from the command line would look like:

sudo tmutil addexclusion /Users/youruser/desktop/somefolder/



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: rossman66 on Sep 13, '11 05:38:52PM

I get a message stating "setdestination requires root privileges." So how are you getting this to run without sudo or typing in a password?

Thanks,
Mark



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: installghost on Sep 15, '11 06:39:10PM

I totally goofed on the permissions for this tip. I am working on a fix right now and will post an update here:

http://backuposx.co/using-two-time-machine-backups-mac-os-x-lion-walk-through



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: installghost on Oct 04, '11 12:54:23PM

autotm is another script that is independent of marcopolo and control plane that can automatically switch time machine destinations. It currently can only switch between time capsules and mac os x servers.

You can read a review about it <a href="http://backuposx.co/autotm-automatically-switching-time-machine-backup-destinations">here</a>



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: arnstein on Sep 19, '11 12:28:29PM

Works nicely for a locally connected usb-drive. But, one of the disks I want to use is a Time Capsule drive with the backup residing on a sparsebundle. How do I use this tip in this context?



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: sven on Sep 22, '11 04:27:59AM

In case anyone's interested, I've put together a ruby script that works without additional software installation. It's available on github And I rant about the motivation in a blog post



[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: sven on May 14, '12 01:54:38PM
I just noticed the provided link does not work. Also, there's been a follow-up blog post in the meantime. Here's the updated link: http://feinstruktur.com/blog/2012/1/2/autotm-094-supports-local-backups.html

[ Reply to This | # ]
10.7: Using two Time Machine backups
Authored by: oneguynick on Dec 29, '11 08:16:45AM
I did a HOWTO on using ControlPlane and a Debian NAS using this as a guide: Geekyschmidt.com Howto for Dual Time Machine Drives

[ Reply to This | # ]