-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-verify
More file actions
31 lines (28 loc) · 965 Bytes
/
backup-verify
File metadata and controls
31 lines (28 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
import time
import smtplib
errors = []
timestampfile = '/media/backup/timestamp.txt'
nowtime = int(time.time())
try:
timestampread = open(timestampfile, 'r').read()
except IOError, e:
errors.append("Timestamp file not found")
else:
try:
backuptime = int(timestampread)
except IOError, e:
errors.append("Timestamp file corrupt")
else:
if nowtime - backuptime > 86400:
errors.append("V1SB backup is more than one day old")
if len(errors):
msg = "From: backup@pelagodesign.com\r\n"
msg = msg + "To: backup@pelagodesign.com\r\n"
msg = msg + "Subject: V1SB Backup Error\r\n"
msg = msg + "\r\n"
msg = msg + "ERROR: The following backup problems were found:\n"
msg = msg + "\n".join(errors)+"\n"
server = smtplib.SMTP('192.168.1.42')
server.sendmail("backup@pelagodesign.com", "backup@pelagodesign.com", msg)
server.quit()