Time machine is really a fine piece of software. The only thing which is missing is some kind of notification when a backup was done (you can open the preferences, but that’s not really satisfying).
So I crafted some little Apple Script:
set console_text to do shell script "syslog -F '$Message' -k Sender /System/Library/CoreServices/backupd -k Time ge -5m" if console_text is not "" then tell application "GrowlHelperApp" set the allNotificationsList to {"Notification"} set the enabledNotificationsList to {"Notification"} register as application ¬ "Time Machine Notification" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Time Machine" notify with name ¬ "Notification" title ¬ "Time Machine" description console_text ¬ application name "Time Machine Notification" end tell end if
Copy it to some folder and register a cronjob, something like this:
*/5 * * * * /usr/bin/osascript /Users/[username]/Public/tm.scpt
Here is the compiled script: Time Machine Notification
If you want to have a shorter/longer interval you need to change the cron line accordingly and the script (it’s the last parameter in the first line, now saying ‘5m’).
Edit: I did what a reader suggested, here is the .plist file.
Tags: growl, leopard, os x, time machine

29 comments
Comments feed for this article
Trackback link
http://www.stopbeingcarbon.com/2008/01/time-machine-notification-with-growl/trackback/
January 3, 2008 at 23:33
Pingback from Stop Being Carbon · Time Machine notifications using launchd
March 25, 2008 at 3:25
Pingback from RAILroading » Blog Archive » links for 2008-03-25
January 2, 2008 at 23:56
T.
Cron job? Shouldn’t it be a LaunchAgent since cron is depricated?
January 3, 2008 at 21:49
Christoph
Good point. Will update it.
January 6, 2008 at 7:43
Jon
I tried this script, and it worked wonderfully, however it only worked once. Subsequent backups have not been shown. Do you have any ideas of why this would be? Thanks.
January 6, 2008 at 13:00
Christoph
Did you use the cron variant or launchd?
January 6, 2008 at 20:32
Jon
I used the launchd
January 9, 2008 at 12:43
Christoph
Sorry for not replying the last few days, my Mac got a new display. Do you see any errors in the console? (should list as tm-notification)
January 9, 2008 at 22:03
Jon
I don’t see any errors, and it actually seems to be working now.
January 11, 2008 at 6:59
Fred
I used the above script and it worked great, but I found it pumped out more information than I needed, so I added some code to exclude some log statements that seemed redundant.
[code lang="applescript"] set consoletext to do shell script “syslog -F ‘$Message’ -k Sender /System/Library/CoreServices/backupd -k Time ge -5m” set modText to trimparagraphs(consoletext) on trimparagraphs(thistext) set the paragraphlist to every paragraph of thistext set the newlist to {} set path_count to 0
repeat with i from 1 to the count of paragraphs of thistext set thisparagraph to item i of the paragraphlist if thisparagraph contains “automatic scheduler” then else if thisparagraph contains “No pre-backup thinning needed:” then else if thisparagraph contains “Trusting backup” then else if thisparagraph contains “getting cat info” then else if thisparagraph contains “Mounting disk image /Volumes/Backups/” then else if thisparagraph contains “Starting post-backup thinning” then else if thisparagraph contains “Trusting backup” then else if pathcount > 0 then — do nothing else if thisparagraph contains “Disk Image Mounted” then set the end of newlist to “Disk Image Mounted” set the end of newlist to this_paragraph
end repeat
set AppleScript’s text item delimiters to return set mod2 to new_list as string set AppleScript’s text item delimiters to “” return mod2
end trim_paragraphs
if modText is not “” then tell application “GrowlHelperApp” set the allNotificationsList to {”Notification”} set the enabledNotificationsList to {”Notification”}
end tell
end if [/code]
I also just used Lingon to set it to run every 5 mins. Thanks a bunch for the script, it was driving me crazy not having updates on the TM status.
January 11, 2008 at 7:01
Fred
I just used codes tags on the above, but it seems to have had its way with the formatting. Sorry about that.
January 11, 2008 at 12:47
Christoph
Thanks for the script, Jon. I tried to put clean up your comment (Wordpress really sucks at posting code as a comment). It’s quite okay now, I guess.
January 11, 2008 at 19:21
Fred
Thanks, for cleaning it up, but it’s still quite messed with html tags and such, so I posted a copy at http://fredandtanya.com/files/GrowlTimeMachineNotification.scpt
January 14, 2008 at 16:22
G
GrowlHelperApp is mentioned in the script however its not found on my system. What was used to load Launchd with the log ’schedule’?
January 14, 2008 at 16:29
Christoph
G, you need Growl installed. What do you mean with your second question? You just need to execute launchctl load /Library/LaunchAgents/com.apple.tm-notification.plist and it should be done (adding the file at first, of course).
January 23, 2008 at 2:52
Nightstrike
Hey, I’m not very good at the technical side of all this. I downloaded the script, just put it in my User folder, and then created the plist file and put it where you said I should. I then inputted that command into Terminal, and it acccepted it. But then, I tested it by running a back up, and no notification showed up. Clearly I’m missing an obvious step… can you tell what it is? I have Growl, so that’s not the problem…
Thanks so much.
January 23, 2008 at 20:25
Christoph
Nightstrike, did you copy it to the public folder in your user profile? Did you adjust the path to the .plist and .scpt file?
January 23, 2008 at 20:27
Nightstrike
Hey actually I fiddled around a bit and realised that I didn’t change the path. It’s now working perfectly (so great work!) Thanks so much.
January 23, 2008 at 20:51
Christoph
You’re welcome, glad it’s helpful.
August 18, 2008 at 1:26
scott
hi, sorry to add a comment so late after the last, but i’m quite interested in this but need some help, hope it’s ok.
i’d love to have growl notifications for time machine but i have to admit that i know nothing about using scripts or registering cronjobs.
could someone please give me a simple step-by-step on what to do? i hate to sound like an idiot but i do need basically everything explaining to me about this.
August 22, 2008 at 22:46
Macroscopic
Nicely done. I’ve got the .plist and growl notifications up and running swell on a 10.5.4 client machine. The Time Machine Notification app lists properly in the Growl Pref Pane and I enables the MailMe plug-in to receive email notifications. Ubür-sweet. However, practicing the identical installation technique I’ve hit a block installing on 10.5.4 Server. All looks correct but the Time Machine Notification app doesn’t appear in the Growl Apps list so I can’t configure it. Poo.
Any ideas if launchd performs vastly different in the server implementation?
Thanks
August 23, 2008 at 9:14
Christoph
@Scott
First you need to take the above Apple-Script and save it to some place (your public directory should be fine). Then you take the .plist file (which you can find here and save it under /Library/LaunchAgents/com.apple.tm-notification.plist. Then you execute the bash line mentioned in the article - launchctl load /Library/LaunchAgents/com.apple.tm-notification.plist. That should be it.
@Macroscopic Nope, sorry, absolutely no experience with Mac OS X Server.
August 25, 2008 at 18:21
scott
thanks christoph, but this hasn’t worked. after i do everything you said, this is what terminal says after the bash line:
http://farm4.static.flickr.com/3265/2796989366186fd592e2o.png
what do you think i could be doing wrong?
August 25, 2008 at 18:22
scott
p.s. sorry about that dodgy link, not sure why only half of it is clickable. here’s a tiny url for it :) http://tinyurl.com/5zdtlo
August 25, 2008 at 19:01
Christoph
no problem. did you save the .plist to /Library/LaunchAgents/com.apple.tm-notification.plist? Because it says that you didn’t.
August 25, 2008 at 19:07
scott
i think i did, well, what i did at first was make the file in textedit then try and save into launchagents but it said access denied, so i saved it to desktop then dragged into launchagents.
here is a screenshot of the file, and the file shown in the launchagents folder in finder.
August 25, 2008 at 19:08
scott
this might help :P http://tinyurl.com/6onawf
August 25, 2008 at 19:16
Christoph
Honestly? I have no idea. Sorry.
August 25, 2008 at 19:17
scott
ok, thanks anyway.