Send background email alert if Time Machine backup fails

I recently released a Mac app called TMNotifier that will run in the background and notify you when a Time Machine error occurs. It also doesn't depend on the default mail client, since it lets you configure SMTP in the app itself.

TMNotifier

Here's an example of what the alerts look like:


This is a great use case for a simple shell or python or ruby script and launchd.

I'll assume you can find on this site how to configure the launchd item or want to buy Lingon which is a great timesaver. (Be aware Lingon 3 is for Lion and there is another also paid version for Snow Leopard just named Lingon on the App store)

You also will need to set up an internal mail server that accepts command line mail from all your clients, so there is that large chunk of setup.

With all that "hand waving" to explain broad concepts - you now could use these core commands to get the job done:

  • tmutil startbackup --block
  • date "+%Y-%m-%d"
  • mail -s "TimeMachine Failure Report from $HOSTNAME" "This mac needs attention"

Depending on how much fun this sounds, you can pick apart each task and work on them or look into software that is designed to do this for you like Apple Remote Desktop or Robot Cloud.