itzg / docker-mc-backup

Provides a side-car container to backup itzg/minecraft-server world data
https://hub.docker.com/r/itzg/mc-backup
MIT License
315 stars 52 forks source link

Detect backup failure in POST_BACKUP_SCRIPT #135

Open Fysac opened 1 year ago

Fysac commented 1 year ago

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

itzg commented 1 year ago

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

jcotton42 commented 1 year ago

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.

itzg commented 1 year ago

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.