(* This is a script to automatically choose which of two volumes to have time machine back up to. If the primary volume is available it will be chosen, otherwise it will choose the secondary volume. If neither is available it will make no changes to the time machine preferences. To use, set the name of the primary and secondary volumes here: *) set primarydrivename to "Backup Drive" set secondarydrivename to "Backup Drive 2" (* Then launch the script whenever you want to change the time machine backup. The excellent utility DSW (http://www.azarhi.com/) can be used to launch the script whenever a volume is mounted or unmounted. The script attempts to use growl to notify the user of its results. Note that GUI scripting must be enabled *) register_growl() activate application "System Preferences" tell application "System Events" tell process "System Preferences" click menu item "Show All Preferences" of menu 1 of menu bar item "View" of menu bar 1 click button "Time Machine" of scroll area 1 of window "System Preferences" repeat until exists window "Time Machine" delay 0.2 end repeat click button 1 of group 1 of window "Time Machine" -- change disk (* If primary disk is mounted switch to it, otherwise switch to secondary disk *) repeat until exists sheet 1 of window "Time Machine" delay 0.2 end repeat set tablecontents to (rows of table 1 of scroll area 1 of sheet 1 of window "Time Machine") set rownumber to 0 set primarydriveavailable to false repeat with tablerow in tablecontents set rownumber to rownumber + 1 set volumename to value of static text of row rownumber of table 1 of scroll area 1 of sheet 1 of window "Time Machine" log volumename if volumename as string is primarydrivename then set primarydriverownumber to rownumber set primarydriveavailable to true else if volumename as string is secondarydrivename then set secondarydriverownumber to rownumber end if end repeat try if primarydriveavailable is true then set desiredrownumber to primarydriverownumber else set desiredrownumber to secondarydriverownumber end if set volumename to value of static text of row desiredrownumber of table 1 of scroll area 1 of sheet 1 of window "Time Machine" select row desiredrownumber of table 1 of scroll area 1 of sheet 1 of window "Time Machine" click button "Use for Backup" of sheet 1 of window "Time Machine" set message to "Time Machine has ben set to backup to " & volumename my growlnote("General Notification", message) on error set message to "Time Machine preferences were not changed" my growlnote("error notification", message) end try delay 1 -- wait for a confirmation dialog that appears if you select a partition on the same physical disk as that being backed up if (exists button "Use Selected Disk" of window 1) then click button "Use Selected Disk" of window 1 end if click menu item "Quit System Preferences" of menu 1 of menu bar item "System Preferences" of menu bar 1 end tell end tell on register_growl() try tell application "GrowlHelperApp" set the allNotificationsList to {"General Notification", "Debug Notification", "Error Notification"} set the enabledNotificationsList to {"General Notification", "Debug Notification", "Error Notification"} register as application "Configure TimeMachine" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "TimeMachine" end tell end try end register_growl on growlnote(growltype, str) try tell application "GrowlHelperApp" notify with name growltype title growltype description str application name "Configure TimeMachine" end tell end try end growlnote