OS X - Apps and Games Discussion of applications and games available for Mac OS X.

How do I script turning Time Machine on and off?


Post Reply New Thread Subscribe

 
Thread Tools
jbrains

 
Member Since: Oct 23, 2007
Posts: 4
jbrains is on a distinguished road

jbrains is offline
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.
QUOTE Thanks
apsharman

 
Member Since: Jul 26, 2008
Posts: 2
apsharman is on a distinguished road

apsharman is offline
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
QUOTE Thanks
apsharman

 
Member Since: Jul 26, 2008
Posts: 2
apsharman is on a distinguished road

apsharman is offline
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
QUOTE Thanks
benignreal

 
Member Since: Mar 14, 2009
Posts: 1
benignreal is on a distinguished road

benignreal is offline
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?
QUOTE Thanks

Post Reply New Thread Subscribe


« Watching Videos | itunes 8.1 issue »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 08:23 AM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?