Time Machine notification with Growl

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: , , ,

Cron job? Shouldn’t it be a LaunchAgent since cron is depricated?

Good point. Will update it.

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.

Did you use the cron variant or launchd?

I used the launchd

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)

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 if

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”}

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 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.

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’?

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).

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.

Nightstrike, did you copy it to the public folder in your user profile? Did you adjust the path to the .plist and .scpt file?

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.

You’re welcome, glad it’s helpful.

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

@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.

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

no problem. did you save the .plist to /Library/LaunchAgents/com.apple.tm-notification.plist? Because it says that you didn’t.

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.

Honestly? I have no idea. Sorry.

ok, thanks anyway.

Ikon Office Solutions Auburn Al New Hendry Bf Goodrich Pro Series Tires Definition Of Solana B B Busing Junction City Kansas Pakistan Indian Sexy Girls Video Colocated Dedicated Hosting Server View Mike Foxx If U Only Knew Mp3 Besito Restaurant Web Site Curb Burner Exhaust Delonghi Hp1500 Panel Heater Martin Roell Motorola Krzr Unlocking Account Sears Summary What Is A Cermet Resistor Gps Mail-in Rebates Tea Ger Ozark Mountain Propane Lanterns Automobile Indusry Abomination Cause Desolation That What Is A Description For Asthma B3468a Pump Assembly Milnerton Tel Collon Gay Video On Logo Mildred Krnacik Mighty Bosstones Wood Mp3 What Fuck Means Westchester Workforce Wheels For Work Program Murphy Bed With Desk Mother Pearl Sconces Cochran Trucking College Park Stores Toronto Maned Flight Saldo Tx Lodging Connecticut Huntersville Loss Weight Clinic Michael Shane Smotherman Lakeland Remax Steve Harvey Mental Health Patient Workbooks Mini Snickers Fruit Salad College Football Odds September 16 Coilover Sleeve 56 Mm Vanity Doctor Restylane Sexy Pirate Boots Milestone Rhododendron Sheikh Antadea Biography Vertical Stripe Golf Shirts What Is Normative Economics Focused On Paintball Tournament In Oklahoma Lakeville Drill And Tapping Gordo Y La Flaca Accident Bus Passengers Sahara Casion Color Concepts Central Ave Toledo Ohio Shopgirl Box Office Micheal Bania Abbotswood Retirement Community Dee Eddington And University Of Michagan Papillotomy Definition Colony Burma Maps Zamboanga City Crystal Reports 6.0 Silent Install Manhattan Luxury Apartment Rentals Shriners Lincoln Ne Osp Indianapolis In About As65v Baby Classic Pooh Lactating Protien Middletown Driving Range Outrigger Catamaran Waikiki Milk And Cookies Myspace Layouts Motorhome Makeover Automobile Dealers Holland Michigan Deana Graybeal Millers Giant Chameleon Mien Furfur Hitler Miller Mgd Nutritional Facts Cocker Color Traits Vehicle Model Search By Vin Technology Manufacturing Military Forms Dd Mango Grill Avid Program El Dorado County Coleoptera Cui Jian Discography Shoe Carneval Fantasy Two Clarinets What Is Radiometric Demolition Hammer Band Ricoh Aficio 2035esp Pantyhose Ankles Man Booker Shortlist 2004 Mini Prox Ii Pbw101 Menorah Ecards Shampoo Cabinets College Jock Hung Medical Exam Sierra Vista Az Hotels Astro Carpet Mill Average Member Processing Days Vdeos Vdeos