Perform multiple includes at the same scope level #732

Closed
opened 2023-07-24 04:04:51 +00:00 by witten · 2 comments
Owner

What I'd like to do and why

In more complex borgmatic configurations, it's not uncommon for a single configuration file to pull in multiple includes for purposes of option reuse. Prior to #721 (removal of config sections), users often did that reuse at the level of one include per configuration section. However, with sections deprecated now (and ultimately going away), that include scope is no longer really available. Which leads to the logical next step of doing those includes at global scope. However, due to a YAML limitation, a single scope can't have multiple "<<:" keys and therefore multiple global includes don't work.

As a solution to this problem, I propose simply allowing multiple file includes in a single include statement. For instance, maybe something like this:

<<: !include [common1.yaml, common2.yaml, common3.yaml]

And this (both supported):

<<: !include
    - common1.yaml
    - common2.yaml
    - common3.yaml

That should work around the YAML limitation and allow the user to perform multiple includes—even if they're all at the same scope.

Other notes / implementation ideas

It would probably make sense for the listed includes to be included/applied in listed order, such that the final include overrides the previous ones.

### What I'd like to do and why In more complex borgmatic configurations, it's not uncommon for a single configuration file to pull in multiple includes for purposes of option reuse. Prior to #721 (removal of config sections), users often did that reuse at the level of one include per configuration section. However, with sections deprecated now (and ultimately going away), that include scope is no longer really available. Which leads to the logical next step of doing those includes at global scope. However, due to a YAML limitation, a single scope can't have multiple "<<:" keys and therefore multiple global includes don't work. As a solution to this problem, I propose simply allowing multiple file includes in a single include statement. For instance, maybe something like this: ```python <<: !include [common1.yaml, common2.yaml, common3.yaml] ``` And this (both supported): ```python <<: !include - common1.yaml - common2.yaml - common3.yaml ``` That should work around the YAML limitation and allow the user to perform multiple includes—even if they're all at the same scope. ### Other notes / implementation ideas It would probably make sense for the listed includes to be included/applied in listed order, such that the final include overrides the previous ones.
Author
Owner

This is implemented in main and will be part of the next release! Documentation here: https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#multiple-merge-includes

This is implemented in main and will be part of the next release! Documentation here: https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#multiple-merge-includes
Author
Owner

Just released in borgmatic 1.8.1!

Just released in borgmatic 1.8.1!
Sign in to join this conversation.
No Milestone
No Assignees
1 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#732
No description provided.