Category Archives: OS X

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 Editor.app from Macintosh HD/Applications/

2: copy and paste this in to the window:
do shell script "defaults write /Library/Preferences/com.apple.TimeMachine 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/com.apple.TimeMachine 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 com.apple.TimeMachine.plist in your systems main library.

Aperture and Time Machine not Sitting in a Tree

Hope Apple fixes this quickly.

After getting a Time Capsule, I’ve started liking Time Machine again. No need to plug in a cable makes a massive difference. Difference between remembering to use it sometimes (I used to share a drive with Darina) and not having to remember to use it, ever.

However, Time Machine doesn’t seem to like Aperture that much, it wants to back up the whole library every single time there’s a change. Apple acknowledges it and suggest turning of Time Machine when using Aperture. I’m not sure if the problem is solved as long as they’re not running at the same time but will try it as soon as these 14.9 gigabytes of images have flown across my flat.

Taking Murphy’s Law into count, there’s a possibility of 2.45/31 for the HDD to die 16 days after turning Time Machine off.

–kristian

AppleScript To Connect To Your Time Machine Backup

Time Machine, no matter how some might say it’s only meant for grandmothers and alike, is so simple and secure to use, it’s would be silly not to. Even if only as an extra layer of data security

For me, the ideal setup is that the Time Machine backup drive lives on my home network rather than directly connected via FireWire or USB. All though Leopard has a simpler way interface for connecting to computers on your network – compared to Tiger – it would be nice to for this to happen automatically. After all, it’s not automatic if you have to think about it.

I’m really just a novice when it comes to AppleScript but luckily it’s a nice and easy scripting language. I wrote the script below to run at login. All it does is it checks which wireless router you’re connected to and if it’s the one you’ve predefined as your home network it then connects to a drive on that network.

set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
if SSID is "xxxx" then --replace xxxx with your chosen wireless network name
tell application "Finder"
mount volume "xxxx" --replace xxxx with the address of your drive. you can find that by 'Get Info' on a mounted drive
end tell
end if

I know this is really basic and could have more features by adding functionality like connecting via the Internet if not at home (I’m actually not sure if that would work with Time Machine) and maybe connecting hourly, rather than just at login. If you want to improve it in anyway please feel free to do so and post your findings below (I’m looking at you Alex).

–kristian

ps. Thanks to StefanK at MacScripter BBS for the SSID bit of the code.

[update] Further investigation reveals that Time Machine automatically connects to networked drives, thus removing the need for the script above. In any case, the script still works, and can be used for other drives you might want to use on a specific network.

Bit More on Leopard Guest Accounts

Another thing I found about Leopard Guest Accounts while I was researching on my previous post about the logs: It’s really easy to change the default which is used to make this account.

Say you want a certain document or a link to a website to appear on the Desktop each time a new user logs in. Remember that you can’t just copy items on the Desktop directly as they get deleted at logout. All you need to do is to add the files/folders you want in this location:

~/System/Library/User Template/English.lproj/Desktop

That location is for a English speaking user and its Desktop folder. Again, admin rights are needed.

–kristian

About Leopard Guest Account

Upon installing OS X 10.5 a new user is created on the system. A guest user. By default this user doesn’t need a password and the parental controls are turned on. This user is not meant to be used for day to day usage and as Apple says, the home folder is deleted at logout. Thus meaning that the user is always ‘fresh’ when next person come to use it.

One thing that is not mentioned in the documentation, is that the activity logs for this user are not deleted, allowing the administrator of the Mac to monitor activity on this user account. There’s also no explicit way of removing the logs. After doing a bit searching, and not finding results, I thought I should figure out how to remove these logs. All though preferences for the user are kept at

~/Library/Managed Preferences/Guest/

, deleting these wont delete the logs.

To remove them, you need to delete folders and files in:

~/Library/Application Support/Apple/ParentalControls/Guest/

Notice that you need to change file permissions in order to reach that directory and use the secure empty trash to delete them.

–kristian

[update: to clarify, the logs hold information such as applications used and websites visited]

tag: Delete OS X 10.5 Leopard Guest Account Log

Gruber, FSJ and 10.5

Just few thoughts for the day ahead:

1. I think there’s a very high likelihood that John Gruber is Fake Steve Jobs. After all. Last couple of days, he’s been at this SXSW 2007 thingy in Texas. This means that he hasn’t been posting links as often as normally on his famous website, Daringfireball.net. Only 3 yesterday, 2 the day before and 1 on the 11th. This is quite few compared to his usual 7-15 posts a day.

Fake Steve Jobs is another busy bee when it comes to blogging. (Actually, too busy sometime, I don’t have enough hours in the day to read all he has to say. Which is a shame because he’s really funny.) But on the 12th his only post was ‘Taking a Break‘. Suspicious. He was taking a break at the same time as Gruber was in this conference.

2. He, Gruber, should send me my t-shirt. It’s really lame not to. It’s also lame not to answer emails from your customers. [Update: If he’s too busy to do this, he should perhaps look into expanding his company and hiring someone to do it]

3. 10.4.9 was released today. Yippee. Only one point from 10.5. What makes this really cool is that, if my memory carries well and it does (compare the point releases of 10.3 to realese of 10.4), that after 10.3.9 there was only two weeks to 10.4. I don’t think 10.5 is so close but I don’t think it’s as far as some people say. Another argument for this would be that WWDC 07 is coming in June and I’d imagine that developers would like to have some experience in using 10.5 before they bombard Apple engineers with questions. (Yes, I do realise that many of them are using the seeded builds already) I’m especially excited about its release as I’ve decided to get a Mac mini as soon as it’s out.

Have a nice day you all,

kristian