Last active
December 8, 2023 23:16
-
-
Save prenagha/8525643 to your computer and use it in GitHub Desktop.
Applescript to monitor age of last time machine backup
and send alert to notification center and email if too old
Set it up in launchd to run daily
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Applescript to monitor age of last time machine backup | |
-- and send alert to notification center if too old | |
-- | |
set tmLatest to do shell script "/usr/bin/tmutil latestbackup" | |
set latest to POSIX file tmLatest | |
set mod_date to modification date of (info for latest) | |
set file_age to round (((current date) - mod_date) / days) | |
log "most recent TM backup " & file_age & " days old" | |
if file_age > 7 then | |
display notification "Most recent TM backup is " & file_age & " days old" with title "Time Machine Backups Not Running!!" subtitle "Contact Admin" sound name "Basso" | |
delay 1 | |
set cn to computer name of (system info) | |
tell application "Mail" | |
tell (make new outgoing message) | |
set subject to cn & " TM Backup Fail" | |
set content to "Most recent " & cn & " TM backup is " & file_age & " days old" | |
make new to recipient at end of to recipients with properties {address:"admin@example.com"} | |
send | |
end tell | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this script would only work if you have an attached TM disk. Check this other script, http://www.fixitscripts.com/problems/script-check-time-machine-backups-and-report-how-long-since-last-good-backup-on-client-daily-report I found.