-TM-hours-Since-Last-Backup ==> full hour since last time machine back up finished
-TM-LastBackup ==> time stamp of last backup.
run this script in a schedule (schedule / server/script) every hour and then do a trigger on any change in variable "TM-hours-Since-Last-Backup" : if variable > 1 then backup is older than 2 hours . You then can send yourself an email ...
- Code: Select all
import subprocess
import datetime
import time
cmd = "/usr/bin/tmutil latestbackup"
statusVariable = "TM-LastBackup"
hoursSinceLastBackup = "TM-hours-Since-Last-Backup"
lastBackupFileName = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
formatOfDateStamp = "%Y-%m-%d %H:%M:%S" # <==== change this to your liking for the variable that will contain the dateStamp
try: indigo.variable.create(statusVariable)
except: pass
try: indigo.variable.create(hoursSinceLastBackup)
except: pass
if lastBackupFileName!="":
theDate = lastBackupFileName.split("/")[-1].strip()
dd = datetime.datetime.strptime(theDate, "%Y-%m-%d-%H%M%S")
outpDate= dd.strftime(formatOfDateStamp)
delta = int( time.time() - time.mktime(dd.timetuple()) )/3600
indigo.variable.updateValue(statusVariable, outpDate)
indigo.variable.updateValue(hoursSinceLastBackup, unicode(delta))
Karl
v 2:
added variable to setup the format of date stamp in your variable (<====)