Make source_directories optional if roots are specified in patterns file #542
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 project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
borgmatic-collective/borgmatic#542
Loading…
Add table
Add a link
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?
Suppose I have the following YAML:
And my
patterns.lstfile has:My understanding is that the 3 lines beginning with
Rare effectively source directories. I'm taking this from the borg documentation on patterns.I'd be happy to make
source_directoriesoptional.. Not just for your use case, but for a variety of other use cases (like having a machine that only runscheck, notcreate). But two notes on that:source_directories"optional" today by setting it to an empty list:[ ]--patterns-frommight take some work with borgmatic, because borgmatic always injects~/.borgmaticintosource_directoriesbehind the scenes. The rationale is that if database hooks are used,~/.borgmaticis where the database dump streaming occurs, and that needs to get backed up. Maybe borgmatic could be a little smarter and only inject~/.borgmaticwhen database hooks are enabled? But then your desired--patterns-frombehavior would break whenever databases are used...I'm interested in hearing your thoughts on this!
Could you take an approach where if
source_directoriesis missing, you initialize it to an empty array, just as if I had done it manually (as explained in your first bullet point)?That way, the logic you have today would still be able to "inject" that path into the empty array.
Not sure if it's that simple, but hopefully so. Thanks for the quick response and being open minded!
That could totally work for
source_directories, but the problem is that when there's anything passed to Borg for source paths, then--patterns-fromroot directories aren't treated at source directories. At least, that's the behavior I'm seeing locally with Borg 1.2.0. Meaning that if borgmatic implicitly injects the~/.borgmaticpath into source directories, your--patterns-fromroot paths will be ignored. I think that's because, as per the Borg docs:The key word there being either.
BTW, is there a reason you want to be able to specify the "source directories" in your patterns file rather than in borgmatic's config file?
I took a peek at the borg source code. It looks like it just parses the
Rpaths out of the patterns file and appends it to the list holding the values passed to thePATHpositional parameter. So they are interchangeable and puttingRin a patterns file is exactly the same as passing it on CLI.Source:
args.pathsvariable defined here (for the positional argument)args.pathsbeing passed to the patterns parsing method invoked when--patterns-fromis specified here (same logic is shared by--patternhere).I think we might be splitting hairs here, but I think the usage of "or" in the docs you quoted is an inclusive or, not an exclusive or. In other words, I think it also is saying you can specify both. Put another way, it didn't say we weren't allowed to.
Like all things... a simple test should be able to prove or disprove this behavior.
To answer your question at the end: I'm aiming for separation of concerns: I'd like the YAML to define configuration-specific (not paths) and have all paths centralized in one patterns file. That way I'm not jumping back and forth between two files when I want to add a root path + specific include/exclude patterns.
Not a huge deal but this is just my personal preference for setting it up.
That totally makes sense as a use case. Thanks for explaining it.
The reason I'm fixated on the "either" is that's the behavior I'm seeing when running a local test. I'm not sure how that squares with the Borg source code appends you're seeing though.
Here's my local test with Borg 1.2.0...
With patterns only:
patterns.lst:
Test run:
(I'm running
createhere without borgmatic so as to verify Borg's own behavior.)With source directories and patterns:
patterns.lst: Same as above.
Test run:
Notice how in the second test, only
~/.borgmaticgets backed up, and patterns are ignored.Now I'd love to find out I'm doing something wrong here, and source directories and patterns aren't mutually exclusive like this. But that does appear to be how Borg is acting.
Related: #574.
Also, the Borg dev seems to think the Borg patterns behavior described above could be a bug, so I've filed it here: https://github.com/borgbackup/borg/issues/6994
location.patternsbreaks when/root/.borgmaticexists #574source_directoriesis now optional, released in borgmatic 1.7.1! And as of #574,~/.borgmaticgets automatically converted into a pattern behind the scenes ifpatternsare specified.Thanks for filing this!