snapshotter icon indicating copy to clipboard operation
snapshotter copied to clipboard

Email on successful/error backup

Open amarc opened this issue 9 years ago • 8 comments

Hi Sean,

I know crontab can email me about tasks but something more "advanced" would be nice in example:

"Successfully backed up Webserver1" or "Backup of Database1 did not finish with error: not enough disk space on device"

Where Webserver1 and Database1 is actually root@Webserver1 of snapshotter line A.

amarc avatar Apr 22 '15 13:04 amarc

Interesting. I wonder if there's a generic "hook" system that could be implemented, so that snapshotter can optionally call a user-specified script on completion and pass in command-line args for success/failure, source and target directories, etc. Then a simple email hook could be written.

seanh avatar Apr 22 '15 16:04 seanh

i'd say a hook-system is advisable. supporting different mail-setups is no fun. and hooks offer far more opportunities.

it's be great if hooks could also be passed as Python callables.

one may also add generally useful solutions as contributed package content.

funkyfuture avatar Jul 29 '15 02:07 funkyfuture

Snapshotter does exit with different exit statuses depending on whether if succeeded or failed, by the way. That along with (possibly) grabbing the last line of its output would allow you to write a script that would run it and send those emails I think

I'm not against a simple hooks system though - would be happy to see designs or even pull requests for one.

seanh avatar Jul 29 '15 07:07 seanh

i'm aware of these possibilities. i just wanted to point out that an implementation of mail notification in this package is propably too much.

funkyfuture avatar Jul 29 '15 13:07 funkyfuture

Yeah I definitely don't want to add code for actually sending emails to snapshotter.

Something close to what @amarc is asking for (an email with one message for successful completion, different messages for different kinds of failure) could probably be achieved by snapshotter just exiting with exit status 0 for success, and different non-zero codes for different failures.

That would be enough for users to write a script to call snapshotter and then send different emails for different exit statuses.

Snapshotter may even do this already -- iirc it usually exits with whatever exit status rsync exits with.

Probably just a case of adding particular exit statuses for ways that snapshotter can fail without even calling rsync, choosing statuses that don't clash with any of rsync's, then documenting them.

That might be the simplest unix-y form of a hook system.

seanh avatar Aug 05 '15 12:08 seanh

or one catches snapshotters output and greps through it.

Am 5. August 2015 14:21:35 MESZ, schrieb Sean Hammond [email protected]:

Yeah I definitely don't want to add code for actually sending emails to snapshotter.

Something close to what @amarc is asking for (an email with one message for successful completion, different messages for different kinds of failure) could probably be achieved by snapshotter just exiting with exit status 0 for success, and different non-zero codes for different failures.

That would be enough for users to write a script to call snapshotter and then send different emails for different exit statuses.

Snapshotter may even do this already -- iirc it usually exits with whatever exit status rsync exits with.

Probably just a case of adding particular exit statuses for ways that snapshotter can fail without even calling rsync, choosing statuses that don't clash with any of rsync's, then documenting them.

That might be the simplest unix-y form of a hook system.


Reply to this email directly or view it on GitHub: https://github.com/seanh/snapshotter/issues/21#issuecomment-127979975

Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

funkyfuture avatar Aug 05 '15 15:08 funkyfuture

My vote is for this to be focused around reliable, sensible and documented exit codes! :+1:

Perhaps writing tests for them would be good, if not done already?

beddari avatar Sep 02 '15 08:09 beddari

We'll definitely write tests when we do this, yes. Honestly, I don't think this is gonna be hard, it's just gonna take a while for me to find the time for it

seanh avatar Sep 02 '15 09:09 seanh