Mar 08, '10 07:30:00AM • Contributed by: Tom_H
#!/bin/bash # This script is run by SuperDuper each time a backup is completed. date "+%s" > ~/.lastbackupThe second script (lastbackup) reads the .lastbackup file and calculates the time elapsed. It takes one argument: the desired number of hours to wait before showing an alert.
If the elapsed time is greater than the time suppled to the script, it shows a Growl notification. If the elapsed time is greater than twice the time suppled to the script, it also increases the priority of the alert (so you can set a diferent colour for it in Growl preferences). Here's the script:
#!/bin/bash USAGE="Usage: $0 [integer number of hours]" if [[ ! "$#" == 1 ]] then echo $USAGE exit 1 fi let "DISPLAYTHRESHOLD = $1 * 60 * 60" # Convert to seconds LASTBACKUP=`cat ~/.lastbackup` NOW=`date "+%s"` let "ELAPSEDTIME = $NOW - $LASTBACKUP" if (( $ELAPSEDTIME > $DISPLAYTHRESHOLD )) then let "OMFG = $DISPLAYTHRESHOLD * 2" if (( $ELAPSEDTIME > $OMFG )) then PRIORITY="2" else PRIORITY="0" fi NICEDATE=`date -r $LASTBACKUP "+%e %B at %k:%M"` # Format date nicely MESSAGE="Your last full backup was completed on $NICEDATE." /usr/local/bin/growlnotify -s -n "Backup Check" -a SuperDuper\! -t "Last Backup" -m "$MESSAGE" -p "$PRIORITY" fi
0 * * * * /full/path/to/lastbackup 24 &>/dev/null[robg adds: I haven't tested this one.]
