This is the specific email check grabber. It fetches an IMAP folder and look for emails following a defined pattern. It will then expose the date of the latest email it could find.
net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabberspecificmail{
"implementation":"net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabber",
"config": {
"ttl": "1h",
"folder": "Backups",
"subjectRegexp": ".Backup of the NAS.*",
"bodyRegexp": ".*Backup and Prune finished successfully.*",
"senderRegexp": "pieroxy@my-server-live",
"imapConf": {
"server": "imap.googlemail.com",
"port": 993,
"credentialsRef": "myusercreds"
}
}
}
TimeThrottledGrabber, you can define ttl and errorTtl. See here for more details. The default ttl is 5 minutes.folder is the IMAP folder in which you look for an emailsubjectRegexp is the regexp used to check against the mail subject. May be ommited.senderRegexp is the regexp used to check against the mail sender address. May be ommited.bodyRegexp is the regexp used to check against the mail body. May be ommited.imapConf Your IMAP configuration.
server is the server. Above you can find examples for outlook and gmail.port is the port, usually 993.credentialsRef Credentials for your user account. See all about credentials for details.Here is the metric this grabber outputs:
num.last_seen The timestamp of the latest message that matches the pattern.borg is a program that runs, deduplicate, compress, encrypt and keep a history of your backups. I'm not going to go into details here, but here is how I operate it:
So, my script, running every three hours, looks something like:
#!/bin/bash
sh /somewhere/borg-run.sh > /tmp/backup.log 2>&1
cat /tmp/backup.log | mail -a "Content-Type: text/plain; charset=UTF-8" -s "Backups `date`" my_email@gmail.com
Here is my configuration for the SpecificEmailCheckGrabber:
{
"implementation":"net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabber",
"implementation":"net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabber",
"config": {
"ttl": "1h",
"folder": "technicalStuff/Backups",
"subjectRegexp": "Backups .*",
"bodyRegexp": ".*Backup and Prune finished successfully.*",
"senderRegexp": "email@sending-address",
"imapConf": {
"server": "imap.googlemail.com",
"port": 993,
"credentialsRef": "myUserCreds"
}
}
}
ttl:1h No need to be too agressive. Plus, a run might emmit a warning because a file was locked and it couldn't read it, so we'll set the threshold to 8 hours before assuming there is an issue.folder:technicalStuff/Backups This is where my gmail filter puts all emails sent by the backup script.subjectRegexp:Backups .* We will only consider emails whose subject start with Backups.senderRegexp:email@sending-address I hardcoded the email of the sender.bodyRegexp:.*Backup and Prune finished successfully.* I only look for emails reporting a successful backup - ie with no warnings or errors. Those will have the sentence Backup and Prune finished successfully somewhere in their body.imapConf That's the configuration of the email account.These conditions all need some attention on my part, so it's good I get an alert.
Yes it is. Yes there are. This example just showcases a workflow. That said, it's not as bad as it looks.
You could very well just call the /emi endpoint on backup completion in the borg script. That would directly ingest the date of the last completed backup into your conkw. That would be more direct, but:
You could have a local instance of conkw that would look inside the log file for a pattern and report back to the central instance. Yes. But both last bullets points above still hold true. And the GrabberFilePattern is still not released.
To sum it up, there is no good or bad workflow. A workflow that is stable, reliable and don't produce false positives is a workflow that works. That's what you need. A workflow that works.