Trying to understand how include & R patterns work #8349
-
Elsewhere in the Q&A, @ThomasWaldmann mentioned that an "R" pattern is essentially like providing the path at the CLI. However, in my testing, it doesn't seem to do this at all. Here is a very simple test I crafted to show this: TO START I have the ~/borgtest3 directory which contains 3 subDirs (3a, 3b, 3c) each with some content. The goal is to to backup only the files in the 3a directory and without borg scanning the entire FS below borgtest3. First, I tried without any patterns or a pattern file and this worked fine. Here is what I did:
However, when trying to achieve he same result using a pattern-file, the R pattern does not work as if I had merely given the path at the CLI as shown above. No matter what I tried, the only way to get the same result was to always specify the full path of the directory containing the files to be backed up. Here are the many pattern iterations I tried along with the result: iteration-1
iteration-2
iteration-3
iteration-4
iteration-5
iteration-6
So it seems all that is really needed is to specify the entire path as an R pattern which then leads to not understanding how an R pattern works with an include pattern when they are the same thing. Clearly I'm missing something here so some clarification would be greatly appreciated. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Ehrm, did I? Do you have an URL? If so, I am sorry, because that would be wrong. It is rather like giving these paths on the commandline to borg to use as root paths (starting paths) for the fs recursion, but it does not do a "change dir".
Then just give the 3a path as root path, that is the simplest way. Giving the full path is best, because it will work no matter from where you invoke the backup.
R means to start the recursion there (which will discover all the file paths below there by default). "+" will try to match the given pattern against the current path from the recursion and add the file to the archive if the path matches the pattern. "-" will also try to match, but won't add the file if the path matches the pattern. "!" is a special thing: it behaves similar to "-", but does not recurse any further if the pattern matches. On Linux, one usually uses this to avoid pointless recursion into /proc or /sys. The first match counts, so order of the patterns is important. Please note that there is no relation between the root paths and the patterns:
This is because borg lets you specify paths and patterns on the cli as well as in the pattern file and it collects paths and patterns in 2 separate lists.
If you give a root path to borg, the default behaviour is to back up all files in there (which is somehow the natural expectation from a backup program). The primary use of "+" is to include some files that would be otherwise excluded by a following (usually more general) "-" pattern. The borg docs and |
Beta Was this translation helpful? Give feedback.
Ehrm, did I? Do you have an URL?
If so, I am sorry, because that would be wrong. It is rather like giving these paths on the commandline to borg to use as root paths (starting paths) for the fs recursion, but it does not do a "change dir".
Then just give the 3a path as root path, that is the simplest way.
Giving the full path is best, because it will work no matter from where you invoke the backup.