Feature request: support the BORG_REPO environment variable #391

Closed
opened 2021-02-18 14:25:12 +00:00 by soyuka · 2 comments

What I'm trying to do and why

My configuration files are meant to be open and public. This is why I tend to remove every private information from these files using environment variables. Currently, the Borgmatic configuration file has one last public information: repositories.

I see that https://projects.torsion.org/witten/borgmatic/src/branch/master/borgmatic/borg/environment.py#L3-L12 supports SSH custom command and the BORG_PASSPHRASE variable which I uses.

Would you accept a patch adding the BORG_REPO variable?

Environment

borgmatic version: 1.5.12

borgmatic installation method: AUR

Borg version: 1.1.14

operating system and version: Archlinux

Sidenote: Is there a way to specify ssh commands per repository?

#### What I'm trying to do and why My configuration files are meant to be open and public. This is why I tend to remove every private information from these files using environment variables. Currently, the Borgmatic configuration file has one last public information: repositories. I see that https://projects.torsion.org/witten/borgmatic/src/branch/master/borgmatic/borg/environment.py#L3-L12 supports SSH custom command and the BORG_PASSPHRASE variable which I uses. Would you accept a patch adding the `BORG_REPO` variable? #### Environment **borgmatic version:** 1.5.12 **borgmatic installation method:** AUR **Borg version:** 1.1.14 **operating system and version:** Archlinux Sidenote: Is there a way to specify ssh commands per repository?
Owner

Sorry for the lengthy delay here, and thanks for filing this ticket. I'm not sure it makes sense to add BORG_REPO though for a couple of reasons:

  1. It would be a little inconsistent to support passing in a repository as an environment variable and not all of the other configuration options in the borgmatic configuration file. But what about all the other supported environment variables such as the ones you linked, you might ask? Those are all environment variables that Borg itself expects to receive, and so borgmatic supports them for Borg compatibility. But borgmatic doesn't currently support any non-Borg-specific environment variables.
  2. repositories is a list! So it'd probably have to be BORG_REPOS and somehow encode a sequence of repositories. This is one reason that borgmatic uses a YAML configuration file with a variety of complex types; it would be difficult (although not impossible) to stuff everything into environment variables.

Having said all that, I do recognize your ask and the underlying need there. So how about this: Have you considered borgmatic's command-line configuration option override support? This would allow you to override the configured repositories whenever you invoke borgmatic on the command-line.

Sidenote: Is there a way to specify ssh commands per repository?

The only way to do that currently would be to create separate borgmatic configuration files, one per repository. Then you could use independent options like ssh_command for each repository.

Sorry for the lengthy delay here, and thanks for filing this ticket. I'm not sure it makes sense to add `BORG_REPO` though for a couple of reasons: 1. It would be a little inconsistent to support passing in a repository as an environment variable and not all of the other configuration options in the borgmatic configuration file. But what about all the other supported environment variables such as the ones you linked, you might ask? Those are all environment variables that Borg itself expects to receive, and so borgmatic supports them for Borg compatibility. But borgmatic doesn't currently support any non-Borg-specific environment variables. 2. `repositories` is a list! So it'd probably have to be BORG_REPOS and somehow encode a sequence of repositories. This is one reason that borgmatic uses a YAML configuration file with a variety of complex types; it would be difficult (although not impossible) to stuff everything into environment variables. Having said all that, I do recognize your ask and the underlying need there. So how about this: Have you considered borgmatic's [command-line configuration option override support](https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#configuration-overrides)? This would allow you to override the configured repositories whenever you invoke borgmatic on the command-line. > Sidenote: Is there a way to specify ssh commands per repository? The only way to do that currently would be to create [separate borgmatic configuration files](https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/), one per repository. Then you could use independent options like `ssh_command` for each repository.
Owner

I'm closing this due to inactivity, but please feel free to post any follow-ups here. Thanks!

I'm closing this due to inactivity, but please feel free to post any follow-ups here. Thanks!
Sign in to join this conversation.
No Milestone
No Assignees
2 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#391
No description provided.