Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (19 sloc) 791 Bytes
### Check if the backup wal-e postgres is executed in the last day
import subprocess
import sys
from datetime import datetime, timedelta
import time
command = "/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-list | tail -1"
p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
output, err = p.communicate()
last = output
last_string = last.split()[1][:-5]
last_datetime = datetime.strptime(last_string, "%Y-%m-%dT%H:%M:%S")
#print last_datetime
last_expected = - timedelta(hours=28)
#print last_expected
if last_datetime < last_expected:
print "CRITICAL: Ultimo backup en wal-e es de mas de un dia, el ultimo es de: %s !" % last_datetime
print "OK. Backup correcto. Ultimo backup es de: %s" % last_datetime
You can’t perform that action at this time.