Make source_directories
optional if roots are specified in patterns file
#542
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?
Suppose I have the following YAML:
And my
patterns.lst
file has:My understanding is that the 3 lines beginning with
R
are effectively source directories. I'm taking this from the borg documentation on patterns.I'd be happy to make
source_directories
optional.. 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-from
might take some work with borgmatic, because borgmatic always injects~/.borgmatic
intosource_directories
behind the scenes. The rationale is that if database hooks are used,~/.borgmatic
is where the database dump streaming occurs, and that needs to get backed up. Maybe borgmatic could be a little smarter and only inject~/.borgmatic
when database hooks are enabled? But then your desired--patterns-from
behavior would break whenever databases are used...I'm interested in hearing your thoughts on this!
Could you take an approach where if
source_directories
is 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-from
root 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~/.borgmatic
path into source directories, your--patterns-from
root 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
R
paths out of the patterns file and appends it to the list holding the values passed to thePATH
positional parameter. So they are interchangeable and puttingR
in a patterns file is exactly the same as passing it on CLI.Source:
args.paths
variable defined here (for the positional argument)args.paths
being passed to the patterns parsing method invoked when--patterns-from
is specified here (same logic is shared by--pattern
here).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
create
here 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
~/.borgmatic
gets 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
source_directories
is now optional, released in borgmatic 1.7.1! And as of #574,~/.borgmatic
gets automatically converted into a pattern behind the scenes ifpatterns
are specified.Thanks for filing this!