Unable to extract when using one repository across multiple configuration files #722
Loading…
x
Reference in New Issue
Block a user
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 want to backup multiple apps to one repo, following the instructions in: How to make per-application backups.
Backup works, but extraction doesn't (without having to specify the config with
-c
).Steps to reproduce (if a bug)
Here are my config files:
common:
/etc/borgmatic/common.yaml
app1:
/etc/borgmatic.d/app1.yaml
app2:
/etc/borgmatic.d/app2.yaml
Create the backup using:
Verify the files are backed up:
Try to extract one of the archives:
Actual behavior (if a bug)
Obviously, using
--repository
doesn't help since it's the same repo in both files. If I do include it, I get:Expected behavior (if a bug)
I'm expecting it to successfully extract the archive, since (a) it's the same repo in both cases, (b) even if they weren't, my archive is only in one of them.
Other notes / implementation ideas
I can work around this by supplying
-c /etc/borgmatic.d/app1.yaml
, but that's a little annoying since the other commands work so well with multiple configuration files.Not the end of the world since I'd presumably not be using
extract
too often... but still.Environment
borgmatic version: 1.7.15
borgmatic installation method: Pacman
Borg version: borg 1.2.4
Python version: Python 3.11.3
Database version (if applicable): N/A
operating system and version: Arch Linux
Thanks so much for taking the time to file this one! I've confirmed the behavior you're seeing locally, and I suspect a little de-duplication in the code throwing that error would solve things. I'll have a look.
Okay, looking at this in a little more detail, here's the rationale for borgmatic erroring with "Repository remote found in multiple configuration files": When a repo exists in multiple configuration files, borgmatic doesn't know which configuration file to "use"; it relies on a particular configuration file to determine how to invoke Borg (with
ssh_command
,local_path
,remote_path
,lock_wait
, etc etc). In your particular case, the two config files look like they're identical from that perspective. But if they weren't, borgmatic would either have to arbitrarily pick one and use its connection parameters or do what it does now—throw up its hands and error.So a couple of ideas I can think of:
--config
as you did to manually select from among configuration files.archive_name_format
ormatch_archives
from each config file to match against the given--archive
and implicitly select the right configuration file that way? Maybe error then if there's noarchive_name_format
or similar to use for disambiguation?Thoughts? Other ideas?
Thanks @witten for the quick and detailed response!
Some thoughts on your ideas:
This would be nice, I'll admit it took me a while to figure out the
-c
workaround.I could think of two ways to do this:
My sense is that (1) would be more generally useful, but also harder to get right. While (2) is more limited, but would solve my particular (maybe common?) use case.
Really? I thought there must be since this error message exists: "Repository remote found in multiple configuration files"
This sounds potentially error prone / hard. However, this other thing you said give me another idea:
There's a third option - execute it on each config. That's what you do for other commands like
delete
.I actually was considering posting a different issue about that. If I do
borgmatic borg delete <some archive name>
with my setup, I see an error message that says something like "archive " doesn't exist.This happens because borgmatic loads the first config, deletes the archive, then loads the second config and can't find the archive.
This is annoying, but also kind of sensible. You could take the same approach with extract and just run it for each config. It shouldn't cause an issue as long as you also filter archives based on
archive_name_format
... which I'm realizing you probably don't for extract. So it might get double extracted. Mmm...IIRC, this is already how repos are compared.
Interesting idea. Yeah, I'm not how feasible that would be given the current includes machinery.
That's accomplished simply by looking for the given repository in each configuration file. That code doesn't have access to the (eventually constructed) Borg commands at that point. For instance, if one config file results in
borg extract --lock-wait 5 user@remote:repo
and the other results inborg extract --remote-path borg1 user@remoterepo
, there's currently no global insight into those two commands.Maybe. It might be as simple though as
fnmatch.filter(user_provided_archive_name, make_match_archive_flags(...))
or something similar.I like the idea. But yeah,
borg extract
doesn't accept anything like an archive name format (or--match-archives
/--glob-archives
) because it only operates on the specific provided archive. But maybe borgmatic could do a first pass and match the archive against thearchive_name_format
before passing anything to Borg. Oh wait, now we're back to "somehow use archive_name_format or match_archives from each config file" above. 😃I have a problem related to this.
I have an automated system that has been backing up data using 50 dynamically config files. Yesterday the service that generated the backup config went down and we lost all the configs. Yay! for not backing those up. Is there a way I can look at the data in the repo? Based on the archive names I will be able to recover or even know what is stored there. Thank you.
A couple of points:
borgmatic bootstrap
action to recover your configuration files from within the repository—even if you didn't explicitly include them in your source directories to backup!borg
directly tolist
,mount
,extract
an archive from a repository made with borgmatic.This is great. Thank you very much.
The archive name format approach proved too complex and not very useful, because often the archive name to match is just "latest"—which doesn't match any archive name formats in any configuration files. So I ended up just removing the restriction that the
extract
andmount
actions must match a single repository. Now they work more like other actions, where each repository is applied in turn.This is implemented in main and will be part of the next release! Thanks for your patience.
Released in borgmatic 1.9.2!