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
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
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.]

