When I run duply, I pipe the results to a log file via the cron job. What would be helpful for me is to have a way to be alerted, via email for instance, if the backup fails for any reason, i.e. where the exit status is > 0. I suppose there are several ways to do this, but I would prefer not to have to edit each new version of duply, which otherwise works great for me, and I think others might benefit from the feature.
Could a post_script be run only in case of error, and only if it exists in the same directory as duply? That way if someone didn't need it, they won't have to do a thing, but others could put what they like in the script to either send a basic email or otherwise alert them to a failed backup.
I had a situation earlier this year when duply and duplicity were mismatched in version so that my backups weren't working. When I stumbled on it, I upgraded duply and all was well, but it worries me now. I don't need to know if it works, there is enough noise for me as it is ;)
Thanks for considering this.
On 12.10.2014 04:21, David Rahrer wrote:
well.. default
duply backup ...
, which translates to
duply pre_bkp_post
actually collects all errors and results in error code 1 if at least one of them failed. make sure that your pre/post scripts always return proper exit statuses or simply do
duply bkp ...
in case you don't need them.
cron already can send emails, why don't you use that feature? redirect all duply output to a log file, best with a date expression into some log folder. if it exits non successful cat the content to to STDOUT and cron will send it to MAILTO.
e.g.
LOGFILE="/var/log/duply/profile.$(date +%Y%m%d).log"; duply bkp profile 1>"$LOGFILE" 2>&1 || cat "$LOGFILE"
possibly. but that's totally different than the current design which works with files from a profile folder and only those.
that's why you should monitor your backups. also verify periodically to prevent silent corruption.
noted. but this is easily possible today without patching duply. alternatively if you can't/won't use cron to send mails you can use condidtions since duply 1.7.0. check the man page (section Usage, Separators)
http://duply.net/wiki/index.php/Duply-documentation
e.g. duply bkp-post profile
..ede
Related
Feature Requests:
#32Thanks a bunch, it appears I simply wasn't creative enough. However, I use the pre/post scripts now to dump databases and clean up the mess after. I could make a conditional bit in the post but according to the man pages, these are the only variables being sent from the main script:
How would I determine the success or failure of the main script for a condition in post? (edit: I can still use $? to get the exit status of the last command since we are still running the same script?)
I can tell I need to work verifying the backups into these commands as well. From what I read, I should be able to do this by using more conditional code in the pre/post scripts to determine what command is running. Just to clarify, if I'm on the first command of a bkp then verify setup, then CMD_PREV='' and CMD='bkp' and CMD_NEXT='verify', would that be correct?
Thanks again, for duply and for the assistance.
Last edit: David Rahrer 2014-10-13
right,
the exit code of the previous command is not exposed to the scripts. probably a good idea to do so.
anyway.. the batch commands are primarily a convenience feature and no replacement for proper shell coding, meaning if you want to more elaborate reaction on failures or such i advise you to simply use several duply calls.
e.g.
(duply pre profile && duply bkp profile) 1>"$LOGFILE" 2>&1 || cat "$LOGFILE"; duply post profile; [ $(date +%u) -eq 7 ] && duply bkp verify 1>>"$LOGFILE" 2>>&1 || cat "$LOGFILE";
run pre and on success run bkp and on failure of one of each print the log so far
always run the post cleanup
on sundays run verify regardless of the success of the commands before. failure handling is analogue to the above
NOTE: verification restores the whole backup for verification purposes, hence results in the same traffic a complete restore would cause.
..ede
Cool. I didn't even realize that "duply humbug pre" would work. Thanks!
just a heads up.. just released 1.9.1 which exports CMD_ERR for use in scripts and now correctly exports CMD_PREV in case commands were skipped due to conditions.
..ede
Excellent, thanks!