Hooks exiting with exit code 1 do not cause backup to fail #214

Closed
opened 2019-09-12 17:14:26 +00:00 by brakhane · 5 comments

Actual behaviour

I have set up a few before_hooks that run scripts that dump data from docker containers
so that this data can be backed up too.

When an error occurs, the scripts exit with error code 1; borgmatic is happy to continue however, causing me to have an incomplete backup without me noticing, since I only get notified when a backup failed.

I can work around it by using "script.sh || exit 2", but AFAICT the documentation does not mention that exit code 1 is treated as success.

Expected behaviour

I expect borgmatic to either stop the backup when a hook exits with 1, or the fact that only 2+ causes the backup to abort to be documented.

Environment

borgmatic version: 1.3.14

### Actual behaviour I have set up a few before_hooks that run scripts that dump data from docker containers so that this data can be backed up too. When an error occurs, the scripts exit with error code 1; borgmatic is happy to continue however, causing me to have an incomplete backup without me noticing, since I only get notified when a backup failed. I can work around it by using "script.sh || exit 2", but AFAICT the documentation does not mention that exit code 1 is treated as success. ### Expected behaviour I expect borgmatic to either stop the backup when a hook exits with 1, or the fact that only 2+ causes the backup to abort to be documented. #### Environment **borgmatic version:** 1.3.14
Owner

Can I have a look at your hook configuration, and perhaps the output of a borgmatic --verbosity 2 run when this happens? That'd help me understand what's going on. As far as I know, the borgmatic code does not treat exit code 1 differently from exit code 2 for purposes of interpreting hook errors.

Can I have a look at your hook configuration, and perhaps the output of a `borgmatic --verbosity 2` run when this happens? That'd help me understand what's going on. As far as I know, the borgmatic code does not treat exit code 1 differently from exit code 2 for purposes of interpreting hook errors.
witten added the
question / support
label 2019-09-12 18:45:33 +00:00
Author
It does: https://projects.torsion.org/witten/borgmatic/src/branch/master/borgmatic/execute.py#L35
Owner

So it does! I forgot that hooks now go through that code path.

So it does! I forgot that hooks now go through that code path.
witten added
bug
and removed
question / support
labels 2019-09-12 20:44:14 +00:00
Owner

This is fixed in master. This fix will go out as part of the next release (hopefully soon). Thanks for reporting it!

This is fixed in master. This fix will go out as part of the next release (hopefully soon). Thanks for reporting it!
Owner

And now released as part of borgmatic 1.3.15!

And now released as part of borgmatic 1.3.15!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#214
No description provided.