Replace Repository while Merging Configs #1328
Labels
No labels
blocked
breaking
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#1328
Loading…
Reference in a new issue
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 try to override the repository via an include.
But it gets added instead of replaced.
Steps to reproduce
config.yaml
<<: !include [/etc/borgmatic/common.yaml, /etc/borgmatic/custom-common.yaml, /etc/borgmatic/custom-config.yaml]common.yaml
custom-common.yaml
Actual behavior
borgmatic config validate --show -nc
Expected behavior
Only the repository in
custom-common.yamlshould be thereOther notes / implementation ideas
No response
borgmatic version
1.8.2
borgmatic installation method
Debian package
Borg version
No response
Python version
No response
Database version (if applicable)
No response
Operating system and version
No response
Merging lists like this is borgmatic's default behavior. If, for a particular option like
repositories, you'd like to retain only the local values and ignore included values, you can use the!retaintag. Here's an example:Alternatively, if you'd like to merge in some list values and omit other values, you can use the
!omittag.Hope that helps!
Thank you for your answer, but i want to archive the opposite.
The last included file
custom-common.yamlshould overwrite the repositories listGotcha. Unfortunately there's not currently a way for an included file's option to override an option in the file that's performing the include. From the documentation:
One idea for a way to solve this with the existing functionality would be omit
repositoriesentirely from yourconfig.yaml. If it's omitted entirely but then therepositoriesoption is pulled in via an include, then that includedrepositorieswill take effect in the merged configuration.Another idea is to reverse the configuration file dependency order completely, such that
config.yamlbecomes the included file andcustom-common.yamlbecomes the main configuration file that performs the includes. In that case, thereposititoriesvalue fromcustom-common.yamlwill have precedence.Hope something like that will work for you. If not, please let me know!