docker-mc-backup icon indicating copy to clipboard operation
docker-mc-backup copied to clipboard

Detect backup failure in POST_BACKUP_SCRIPT

Open Fysac opened this issue 2 years ago • 3 comments

It would be nice for POST_BACKUP_SCRIPT to be able to detect when a backup failed, so that it can send out a notification in case of an error (e.g., an unhandled restic state). This was one of the use cases for the feature originally described in #89, but I don't see any way for a post-backup script to currently tell if something went awry.

I think all this would take is passing the exit code (and possibly some stderr output?) from the backup stage as an argument to the script on this line: https://github.com/itzg/docker-mc-backup/blob/037f49dfbbe60b261a4433e811d6ac631f280df4/backup-loop.sh#L499

Fysac avatar Apr 08 '23 19:04 Fysac

@jcotton42 can you confirm this was absent from your PR. Since you mentioned the use case, it seems like you have included it.

itzg avatar Apr 09 '23 21:04 itzg

It was something I meant to address, but never got around to doing so. Passing the exit code would likely suffice, though I think the set -e at the start of backup-loop.sh might have to be removed? Or at least disabled for the line that runs the backup. Since iirc that makes bash bail on the first command that dies.

jcotton42 avatar Apr 09 '23 22:04 jcotton42

Cool. Just wanted to check. I believe putting the invocation in a conditional should satisfy the -e constraint.

@Fysac if you're interested in PR'ing this, then that would be great.

itzg avatar Apr 09 '23 23:04 itzg