borg icon indicating copy to clipboard operation
borg copied to clipboard

re: patterns not accepted for prune

Open travisdowns opened this issue 5 years ago • 8 comments

Have you checked borgbackup docs, FAQ, and open Github issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

Maybe either.

Borg 1.11

It seems like re: patterns are not accepted for the --glob--archives option of prune.

It is not clear from the documentation whether this is by design. The doc says "sh: rules apply, see “borg help patterns”", but the pattern help indicates you can override the default using the various prefixes.

It would be nice to support re: patterns as they are the only way I can see of excluding some archives from pruning (unless the archive naming happens to work out for a "positive" glob). E.g., I want to keep my oldest archive, and I could do that using --glob--archives with a re: pattern and negative lookaround.

travisdowns avatar Aug 01 '20 20:08 travisdowns

Well, guess this is by design. And if it says "sh: rules apply", that does not imply that you can use the other patterns also.

But I see your point, so maybe this could be generalized (sh: would need to stay the default, of course).

PRs welcome.

ThomasWaldmann avatar Aug 15 '20 17:08 ThomasWaldmann

Seems to be by design, but maybe allowing the other patterns can be a good idea as well? I can do this, I have started looking at the code in order to understand the logic and be more efficient if I have to work on this section of the code

Gu1nness avatar Oct 19 '20 13:10 Gu1nness

@Gu1nness PRs welcome. Try to reuse code from existing patterns matching, if possible.

ThomasWaldmann avatar Oct 19 '20 15:10 ThomasWaldmann

Hi, I am looking to start contributing to open source projects and I was wondering if I can pick this one - if it's still open for grabs. Thanks!

preetisi avatar Aug 09 '21 18:08 preetisi

@preetisi sure, it is still open. maybe first think about how to solve it best, discuss it here, implement tests + code, do a PR early.

ThomasWaldmann avatar Aug 09 '21 20:08 ThomasWaldmann

So from my understanding:

Rather than having a --patterns-from option for example, prune gets --glob-archives from define_archive_filters_group. Since the type is GlobSpec, this implies that only sh: rules apply (makes sense since it's globbing). If we were to allow re: and other patterns in prune, then it would make sense to replace glob-archives with pattern is my thinking? Would bring it more in line with other commands at the cost of backwards incompatibility.

remyabel2 avatar Aug 26 '22 07:08 remyabel2

Yeah, naming it "glob-..." when not (only) doing globbing is maybe a bit strange.

As we'll break some stuff anyway in borg2, we could also rename that. Guess that would be good also considering that "glob..." is a rather technical term.

How about --match-archives as long version of -a, supporting prefixes like re:, sh:, etc. and defaulting to globbing?

ThomasWaldmann avatar Aug 26 '22 09:08 ThomasWaldmann

see #7028.

ThomasWaldmann avatar Sep 17 '22 12:09 ThomasWaldmann

Thanks @ThomasWaldmann - your dedication to this free product is much appreciated!

travisdowns avatar Sep 27 '22 22:09 travisdowns