Scheduling Time Machine Backups with AppleScript and iCal

Great news to all Time Machine users! It’s actually possible to schedule when you allow backups to happen. Problem has been that Time Machine tends to go on at times when it’s really not that convenient; when your working on something heavy and don’t want the extra CPU usage or when you need to leave your flat but don’t want to abruptly stop it backing up (latter can be really harmful to your backup so should be avoided). Two lines of AppleScript and few iCal events will fix this!

Few easy steps:

The Script

1: Open Script from Macintosh HD/Applications/

2: copy and paste this in to the window:
do shell script "defaults write /Library/Preferences/ AutoBackup -bool true"

3: Save As: “TM-On” in Macintosh HD/Library/Scripts/Time Machine/

You don’t need to change the defaults

4: Open a new document in Script Editor

5: copy and paste this in to the window:
do shell script "defaults write /Library/Preferences/ AutoBackup -bool false"

6: Save As: “TM-Off” in Macintosh HD/Library/Scripts/Time Machine/

In iCal

(As there’s going to be repeating calendar entries for every day I’d suggest adding a new calendar so you can hide it.)

1: Create a new calendar entry for today.

2: Decide what time you want to turn Time Machine on. I’ve set it to 13:00 so it’ll be on when I get home. Also set it to repeat daily.

3: Set Alarm to Run Script and underneath File… and browse to /Macintosh HD/Library/Scripts/Time Machine/TM-On.scpt

4: Set it to go 1 minute before the event (if you set it to ‘on date‘, repeat wont work)

5: Repeat above steps for turning Time Machine of and you’re done. I’m turning mine off in the wee hours of the morning but if you like watching stuff on you laptop in bed you might want to turn it off – say – 21:00 so it won’t be backing up when you want to go to sleep.

6: Relax… or watch the video below. It shows how this is done in about 4 minutes. Click here to watch this video in HD on Vimeo.

[Update 1] If you’re having problems using this, it might be that you don’t have a .plist for Time Machine. As odd as it sounds, Darina’s MacBook was missing this completely. In order to create it, just go to TM preferences and add something to the excluded list. This will create a file called in your systems main library.

16 thoughts on “Scheduling Time Machine Backups with AppleScript and iCal

  1. Michael

    Interesting. What I would like to do is have time machine be Location Aware. That way, when I’m at home where the Time Capsule is, Time Machine backs up hourly. And when I’m somewhere else, with no backup drive available, it stops trying to backup. My location isn’t based on calendar timing, so the ical thing doesn’t really work. Now I just manually turn it in on or off, but it would be nice to automate it.

  2. kristian


    It’s looks like what you need is MarcoPolo. It detects your location based on rules like which wifi networks are available and changes you computers settings accordingly. It doesn’t seem to support TM directly but with the above shell script that’s not a problem. fyi, I haven’t used MarcoPolo myself but have heard good things about it.

    For me the problem with TM is that it often starts backing up at the wrong time, like just as I’m leaving the flat. And, as you must know, TM really doesn’t like being interrupted. Especially when used with Time Capsule.

    Hope this helps!


  3. Easton

    Hello Kristian…I just found this as I was tired of all the hourly backups, very nice. I do have one question though, what issues will arise if the TM-off script happens when the time machine is in the process of backing up? I now have it scheduled to TM-on at 1:00am and TM-off at 3:00am daily as once a day backups are fine for me

  4. kristian

    Hey Easton,

    As far as I know, if it’s turned off during a backup, it’ll just finish doing it remains turned off after that. I guess one way to make sure you get at least one ‘clean’ backup would be to make the window longer, say, 00:00 – 06:00. That would be enough to backup pretty much any amount of data over a USB. Time Capsule or backup over wifi is pretty slow so it’ll need longer.

    Hope this helped!

  5. kristian


    Good point. I’ve looked at Time Machine Editor previously and at the time you could only set intervals by the hour. It seems to have come a long way since then. Thanks for pointing that out.


  6. Easton

    Hi Kristian…

    How would you set this up if you want a backup to run more than 1 time per day? I have tried everything and it will only run one time per day. I would like to have one in the early morning and one in the early afternoon.


  7. Kristian

    Hey Easton,

    Have you tried setting the scripts to be run by iCal twice a day? I’d set them so Time Machine is on for 2 hours from, say, 05:00 and then 2 hours from 12:00. That way there’s a big enough window for it run few times and make sure you get a good backup.

    I’d try Time Machine Editor as well, see link in above comment. It looks like it does a lot more now than it used to.


  8. Tim


    Just curious…is WHERE you save/run the two scripts critical? I quickly copied and pasted the scripts into a sub-folder in my Documents folder. The two scripts appear to have run last night, but a backup did not occur. Then, when I ran a manual back-up this morning, it finished abnormally quickly. Is it possible that I adversely altered something?


  9. Kristian

    Hey Tim,

    If your backups have run fine through the night, manual backup won’t take long. Especially with FireWire/USB. Also, location of the scripts won’t make a difference, but I like to keep them at above location as then they’ll appear in the scripts menu.

    Hope this helps!


  10. Tim

    Hi Kristian – All seems to be fine now. I’m assuming that these scripts shoud run at night even when the systme is in sleep mode? Is there anything that I can put in the script to “waken” the system to insure that the back-up does occur or is that even necessary?

    Thanks for your help – Tim

  11. admin

    Hey Tim,

    You can’t use an AppleScript to wake up but if you go to System Preferences > Energy Saver > Schedule… you can schedule it from there.

    If you prefer to mess with the command line, find out about pmset command line tool that you can use to do the same.

    Good luck!


  12. kevin

    Hey – Kristian,
    Trying to schedule TimeMachine ON/OFF with iCal. Copied scripts to script editor, compiled and tried to run as shown in the video. This did not turn TM ON or OFF. Any ideas?


  13. James

    I’ve donated my Time Capsule to my mom, who is using her mifi hotspot or other borrowed networks to get on the internet. In other words, when it’s time to back up to the Time Capsule using Time Machine, she will have had to switch to the local network that the time machine is on, which will unfortunately be something other than what she’s getting her internet from.

    As a consequence, what if I need the script to first change network to the one created for the Time Capsule, then go back to another wifi network by the morning? What would be the exact syntax for the script? I’ve renamed her locations and played with toggling:

    do shell script “scselect ‘{Home}”
    do shell script “scselect ‘{Home Backing Up}”

    but it doesn’t do the trick: my syntax could be off, and I’m facing an additional problem. the location based list of networks still seems to favor getting me on the Home network connected to her mifi device, and changing network preferences does not seem to cooperate why I try to convince it to create a network location that doesn’t actually have internet access. So would I need to make the Time Capsule network a local network, and how would that add into the procedure and the script?

    Thanks plenty! I’ve looked for any and all sites that spell out the script correctly, and haven’t found one to fit my particular situation.


Leave a Reply

Your email address will not be published. Required fields are marked *