How do I script turning Time Machine on and off?

Joined
Oct 23, 2007
Messages
4
Reaction score
0
Points
1
Hello, there. I'm a programmer, but I don't know Applescript nor its APIs. Now I imagine it's time for me to learn.

I run hourly Time Machine backups, then nightly SuperDuper! backups. I'd like to stop Time Machine while SuperDuper! runs. Since SuperDuper! gives us hooks to run a script before and after a backup, I'd like to know how to change the on/off preference in the Time Machine preference pane. Who's willing to point me in the right direction? Google searches were surprisingly fruitless.

Thanks for your time.
 
Joined
Jul 26, 2008
Messages
3
Reaction score
0
Points
1
Hi jbrains,

Although it's been nine months since you made this post, I just found it today. Also, I just found the answer to your question today. The following AppleScript uses a shell script to make the changes. The only thing you need to do is to change the name of the Time Machine volume to match yours.


if (list disks) does not contain "TimeMachine" then

-- If TimeMachine is not mounted, turn it off
do shell script "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 0"
else
-- Turn it on
do shell script "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 1"

end if


Hope this helps.

Cheers, Tony
 
Joined
Jul 26, 2008
Messages
3
Reaction score
0
Points
1
Hello again,

There was an error in my code. The correct code is:

if (list disks) does not contain "TimeMachine" then

-- If TimeMachine is not mounted, turn it off
do shell script "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -bool false"
else
-- Turn it on
do shell script "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -bool true"

end if

Sorry about that, Tony
 
Joined
Mar 14, 2009
Messages
1
Reaction score
0
Points
1
Thanks apsharmin for the script

What I've been trying to figure out unsucessfully is how to make TM on my mbp location aware so that it is enabled if it detects a certain network and disabled otherwise. That way it only tries to run if the external HD is available. Thoughts on how to do that?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top