Setting prefix of repository path from commandline #782
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#782
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'm using borgmatic 1.8.4 on debian 12 and try to replace a prefix to the repository name from command line.
According to your documentation you support default substitution on environment variables.
The standard call to make a backup should be
borgmatic create
But sometimes I want to use the same conf files in
/etc/borgmatic.d
to use a different disk on a different computer and start the backup withBORGMATIC_PREFIX='ssh://user@myothercomputer/someother/path' borgmatic create
So I created the conf files like this:
But I always get the same error message
with or without setting the environment variable.
As soon as I replace the environment default expression
${BORGPREFIX:-ssh://...}
with a simple expression${BORG_PREFIX}
everything works fine. But i have no default value :-(I also tried setting a constant
and overriding it with
--override 'constants.borg_prefix=ssh://user@myothercomputer/someother/path'
but this has no effect: borgmatic accesses the original path.Can you tell me what I'm doing wrong? Or do you have another solution?
regards Volker
Steps to reproduce
see above
Actual behavior
see above
Expected behavior
see above
Other notes / implementation ideas
No response
borgmatic version
1.8.4
borgmatic installation method
debian package
Borg version
1.2.4
Python version
3.11.2
Database version (if applicable)
No response
Operating system and version
Debian 12
Thanks for taking the time to file this! For this first issue with this configuration ...
... I was able to reproduce the behavior you're seeing. However, the environment variable substitution—even falling back to a default value—works just fine for me when I make use of the environment variable anywhere other than for the
path
. For instance, try making use of an environment variable (with or without a default) for thelabel
value, and you'll see that it works just fine. I think what's going on with thepath
though is an unfortunate interaction with the logic that rewrites non-ssh://
style repository URLs. That logic is triggering before the environment variable substitution happens, thereby screwing everything up.Side note: You have
BORGMATIC_PREFIX
in your command-line invocation butBORGPREFIX
in your configuration file, so make sure those environment variable names match up!As for the
--override 'constants.borg_prefix=ssh://user@myothercomputer/someother/path'
issue, I expect you've found another unfortunate interaction: Most likely, overrides don't work with constants because constant interpolation happens before overrides kick in. I'll have to look into whether it's possible to fix that or not.I'm going to go ahead and mark this ticket as a bug, but I don't yet know what all is fixable or work-aroundable. In the meantime, I recommend using a separate configuration file for your second repository. You can take advantage of configuration includes if you don't want to duplicate settings. In fact, this may ultimately be a more convenient longer-term approach, so you can just select the configuration file you want to use instead of typing so much on the command-line. Having said that, I still want to address the two issues you've highlighted.
An update: I've fixed the first issue in main by swapping the order of environment variable interpolation and normalization (like repository URL rewriting), so environment variable interpolation comes first.
Still to do: Figure out what to do for the other issue with the overrides.
The override portion of this ticket has been fixed in borgmatic 1.8.5, just released. (This also includes the previous fix for the environment variable issue.) Thanks!