I am using a the following backup script to backup a server to USB.
USBBackupScript - RdiffBackupWiki
However I don't know python and would like to alter the script so I can send emails about the success or failure of the backup to multiple recipients.
I did do some research but the limit of my expertise is bash scripts at present and so I would appreciate some help.
The relevant code sections from the script are:
def emailReport(report):
msg = email.MIMEMultipart.MIMEMultipart()
msg["To"] = config["email.to"]
msg["From"] = config["email.from"]
if (report.success):
msg["Subject"] = config["email.subject"] + " - SUCCESS"
else:
msg["Subject"] = config["email.subject"] + " - FAILURE"
if (dryrun):
msg["Subject"] += " *** DRY RUN ONLY ***"
msg.preamble = "Mime message\n"
msg.epilogue = ""
msgBody = email.MIMEText.MIMEText(report.email)
msg.attach(msgBody)
logAttachment = email.MIMEText.MIMEText(report.log)
logAttachment.add_header("Content-disposition", "attachment", filename="backup_log.txt")
msg.attach(logAttachment)
smtp = smtplib.SMTP(config["email.smtp_server"])
smtp.sendmail(config["email.from"], config["email.to"], msg.as_string())
smtp.quit()
And the config's are read from the ini file, specifically:
# enable sending of reports by email
enable = yes
# from and to addresses
from = rdiff-backup-usb@example.com
to = backupmaster@example.com
# base subject line for the email
subject = Backup: MYSERVER
smtp_server = localhost