Hook "on_warning" #606
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#606
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I would like to have a hook (preferebly ntfy) fired, when borg exits with a warning (exit code 1). This would be helpfull, when you try to backup a folder that doas not exist. This could happen when a folder gets moved without your notice.
Other notes / implementation ideas
A config.yaml, after implementing this could look like following:
Environment
borgmatic version: [1.7.4]
borgmatic installation method: [pip --user]
Borg version: [1.2.2]
Python version: [3.10.7]
Database version (if applicable): [version here]
operating system and version: [Linux 5.15.74-3-MANJARO]
To clarify, would either the proposed ntfy-specific
warn
hook or theon_warning
command hook meet your needs? Or do you foresee a need for both? Related tickets: #366, #518, #592.Personally i use ntfy, so i only need the 'warn' hook. But i think an 'on_warning' hook would be usefull in other configurations.
If you agree, that this sounds usefull, i could create a patch.
I apologize for the delay here. I would be totally fine with an ntfy "warn" state being supported; I just don't know how easy it would be to add. That's because right now, borgmatic only differentiates between Borg success and failure. A warn state (exit code one, e.g. files missing) is silently treated as a success. So that would have to change in order for the warn state to be available for plumbing through to the ntfy hook.
Having said that, a PR would be welcome if you're still up to it! I'd be happy to answer questions as you go.
And here's an alternate idea that may or may not meet your needs: In the next release (1.7.10), there will be a new option in configuration called
source_directories_must_exist
(implemented in #501), which you can set totrue
if you'd like borgmatic to check that source directories exist before calling Borg. If they don't exist, borgmatic will error and presumably notify ntfy of the error. (Note that the existence check is not recursive currently.)Nice to here from you.
source_directories_must_exist
is very cool, but stops, i only want to get warned.Here's an alternate idea: The
source_directories_must_exist
option effectively triggers a pre-check before Borg even runs; borgmatic probes for each source directory existing and errors if any don't. So if the primary thing you're interested in is whether configured source directories exist, what if borgmatic just issued a warning to ntfy whenever they didn't? It could use the same pre-Borg probing mechanism. That might be easier than checking every call to Borg for warning exit codes. The main downside is that it wouldn't handle other Borg warning states.Closing for now in favor of
source_directories_must_exist
. But we can always reopen and revisit this later.