garethgeorge/backrest

CONDITION_SNAPSHOT_END run even on job failure.

Closed this issue · 4 comments

Describe the bug
The CONDITION_SNAPSHOT_END hook runs even if the backup job fails. This makes it impossible to externally track backup status with services like healthchecks.io that expect failed backup operations not to report back.

To Reproduce
Steps to reproduce the behavior:

  1. Create a backup job that will fail (e.g: two concurrent jobs on the same repo and no "Auto Unlock" option set)
  2. Add a command hook for CONDITION_SNAPSHOT_END
  3. Run the backup
  4. Whatever command you've put in the hook gets executed anyways.

Expected behavior
The hook on CONDITION_SNAPSHOT_END should only run if the backup job exited without errors.
For failed jobs we already have CONDITION_SNAPSHOT_ERROR and CONDITION_SNAPSHOT_WARNING.

Platform Info

  • Arch Linux
  • Backrest 1.0.0

I recommend the pattern here https://garethgeorge.github.io/backrest/cookbooks/command-hook-examples#notify-a-healthcheck-service for healthchecks.io . The way CONDITION_SNAPSHOT_END is intended to be used is that you can check for .Error to know if an error occurred.

I think it's a good point that there should be a hook class that only runs on success, it's a weird choice that CONDITION_SNAPSHOT_END runs irrespective of the outcome. To preserve it's behavior I'll probably add a new CONDITION_SNAPSHOT_SUCCESS hook or similar.

Thanks for the hint!
Having a CONDITION_SNAPSHOT_SUCCESS hook would be reasonable I think :)

Can we please get a new release with hook behavior fixes? :)

Done, this is included in 1.2.1 thanks all for the patience!