Configuration-specific healthchecks hook but other common hooks in a single !include file #579
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#579
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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 be able to specify a common set of options from a "!include" file yet also have a specific per-configuration healthchecks URL.
Steps to reproduce (if a bug)
I know the !include here is wrong, but this is the general idea:
Actual behavior (if a bug)
Expected behavior (if a bug)
Other notes / implementation ideas
It seems this is a limitation of the python parser from some Google searching, but I'm wondering if there is some other way to achieve this. I'd like to have a full suite of standard hooks (before_backup, after_backup, etc.) using existing variables like "{configuration_filename}" and some custom scripts (Slack webhooks, for example) for echoing some verbose output to stdout and performing some custom hooks using curl and such without having to update a bunch (28) of borgmatic configuration files if something changes.
I have a specialized backup scripting environment and borgmatic is called inline within a larger job along with several other functions performed during maintenance. Everything to stdout is captured and parsed and displayed elsewhere so even "echo" statements are helpful for monitoring job progress.
Environment
borgmatic version: 1.7.1
borgmatic installation method: pip
Borg version: borg 1.2.2
Python version: Python 3.10.6
operating system and version: MacOS 12.5.1 and Debian 11.4
Try it like this:
config.yaml:
common_hooks.yaml
Thanks for commenting.. Yes, that looks like it would work! The key detail is that the plain
!include
style of include is only for pulling in individual values. If, instead, you want to reuse configuration keys and values, you'll need the<<: !include
style merge include.I bet the following would also work if you want an even more targeted include:
config.yaml:
common_healthchecks.yaml:
I'll close this for now, but please feel free to post any follow-up questions here.
I'm not sure the two examples address what I was asking unless I'm missing something. All they appear to do is move the problem to a common external file instead of the main configuration file.
Putting "ping_url" in the example "common_healthchecks.yaml" still means I would have one unified hc-ping.com URL called by every backup configuration.
The goal would be to have a common set of actions for the standard hooks (before_backup, after_prune, etc.) but maintain separate hc-ping.com URLs for the "healthchecks" in each backup configuration file.
Oh, my bad.. I misunderstood. If you want a different Healthchecks ping URL in each of several configuration files and a common set of other hooks shared between them, you can do something like this:
standard-hook-actions.yaml:
individual_backup_configuration.yaml:
Does something like that work for your use case?
It looks like it will at face value. I'll check it out early next week. I've been migrating several repos to new hardware this week and imposed a configuration freeze until that was complete today.
Great, I'll leave this open for now until you can confirm one way or the other. I hope it works out!
Just tried this on a simple test configuration with some simple "echo" outputs and it seemed to work. I think this is good to go but I'll migrate it to a couple production configs and make sure. You can probably call this closed.
Thanks for sticking with it. Much appreciated.