borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11.22k stars 743 forks source link

pattern matching, docs vs. reality #7634

Open ThomasWaldmann opened 1 year ago

ThomasWaldmann commented 1 year ago

While dealing with #7631, we noted that this patterns file does not work as I expected:

P sh
R /Users/tw/w/borg
+ Users/tw/w/borg/src
+ Users/tw/w/borg/src/borg
+ Users/tw/w/borg/src/borg/helpers
+ Users/tw/w/borg/src/borg/helpers/**
- **

The idea was to include the parent dir fs items (only the 3 directory items src, borg and helpers, not the files inside), then include the desired files (here: all inside helpers) and exclude everything else.

Issue: It included all below Users/tw/w/borg/src into the backup archive (not just the dir items and the files in helpers).

So it seems not to work as I thought it would (I personally do my backups the other way: include all, only exclude what I do not want).

Update:

This is already enough to get that behaviour:

P sh
R /Users/tw/w/borg
+ Users/tw/w/borg/src
- **

Reproduced with borg 1.2.3, 1.2.4 and 1.2-maint git branch.

ThomasWaldmann commented 1 year ago

Using pf: prefix only for the parent dirs makes this work as desired.

ThomasWaldmann commented 1 year ago

I had a look at borg.testsuite.patterns and now I think we need a rewrite of pattern docs and tests in a way that the docs and tests precisely reflect each other.

The input file paths in the tests should better reflect real use cases as encountered on typical linux filesystems and backup scenarios.

Also, I guess there need to be some simplifications and less magic behaviour, KISS (keep it simple and stupid).

As this might change matching behaviour, guess this is a borg2-only change.

ThomasWaldmann commented 1 year ago

Depending on the changes done in this refactoring, this might be a breaking change.

Like: the users need to verify whether their patterns still work as intended and fix them if needed.

c0d3z3r0 commented 1 year ago

Maybe also add appropriate test cases to the testsuite

ThomasWaldmann commented 1 year ago

@c0d3z3r0 https://github.com/borgbackup/borg/issues/7634#issuecomment-1584890185