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
-
Cron job? Shouldn’t it be a LaunchAgent since cron is depricated?
-
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.
-
I used the launchd
-
I don’t see any errors, and it actually seems to be working now.
-
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
else if this_paragraph contains "rebuild path cache" then set path_count to 1 set the end of new_list to this_paragraph else set the end of new_list to this_paragraph end ifend 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"}
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 modText ¬ application name "Time Machine 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.
-
I just used codes tags on the above, but it seems to have had its way with the formatting. Sorry about that.
-
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
-
GrowlHelperApp is mentioned in the script however its not found on my system. What was used to load Launchd with the log ’schedule’?
-
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.
-
Pingback from RAILroading » Blog Archive » links for 2008-03-25 on 2008/03/25 at 03:25
-
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.
-
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
-
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?
-
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
-
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.
-
this might help :P http://tinyurl.com/6onawf
-
ok, thanks anyway.
-
I figured out how to do this without applescript… The growl package comes with an optional command-line tool called growlnotify. If you install that, you can run this shell script from launchd, and it will do the job
!/bin/sh
status=
syslog -F '$Message' -k Sender /System/Library/CoreServices/backupd -k Time ge -5mif [ "$status" != "" ] ; then /usr/local/bin/growlnotify -n “Time Machine” -m “$status” fi
-
grrr… your comment system took out all of my carriage returns and backticks… the script won’t run as it shows up in my last comment
-
So, it’s been a while, and this script was great, but since there’s now the menubar icon for time machine, I don’t think I really need it. Can I just delete the scpt and plist files and then I’ll be all set? Or is there something else that I’ll have to do in order to make a clean deinstallation. Thanks!
-
Well, tried the cli version. But did not work straight away… Took some time to figure out what went went wrong.
Solution:
!/bin/bash
status=
/usr/bin/syslog -F '$Message' -k Sender /System/Library/CoreServices/backupd -k Time ge -5mif [ "$status" != "" ] ; then /usr/local/bin/growlnotify -n “Time Machine” -m “$status” –image /System/Library/PreferencePanes/TimeMachine.prefPane/Contents/Resources/TimeMachineGraphic.png > /dev/null 2>&1 fi -
Hi,
I was trying to use Nefkens solution but I have no idea where to run that command… I have managed to install growlnotify by simply running “./install.sh” it now says “add /usr/local/bin to you PATH” but I’m hoping that’s already been done…
But what do I need to do next? Tak
-
Ha looks great, but syslog crashes on me on my machine
[ Cassandre:: 20:51] [~] # syslog -F ‘$Message’ -k Sender /System/Library/CoreServices/backupd -k Time ge -1m syslog(89548) malloc: *** error for object 0×107cc0: double free *** set a breakpoint in mallocerrorbreak to debug Segmentation fault [ Cassandre:: 20:51] [~]
And any variation on the syslog commands also segfault.
Any one has a clue ^

38 comments
Comments feed for this article
Trackback link: http://www.stopbeingcarbon.com/2008/01/time-machine-notification-with-growl/trackback/