borg icon indicating copy to clipboard operation
borg copied to clipboard

`--glob-archive` does not work with regexp in borg list

Open knutov opened this issue 2 years ago • 7 comments

Not sure, may be not 1.2 version specific, but --glob-archive does not working with regexp:

borg list user123.mysql --prefix user123-2 | awk '{print $1}'
user123-2022-03-20-065449
...
user123-2022-03-28-031228

borg list user123.mysql -a "re:^user123"
# empty output

In my scenario I have to select snapshots to prune with filter based on prefix (exact match) and suffix (regexp), Seems to be not possible now.

From https://borgbackup.readthedocs.io/en/stable/usage/list.html:

only consider archive names matching the glob. sh: rules apply, see “borg help patterns”.

There is nothing about other patterns should not work in case they are specified, and there is definitely should be the way to select snapshots by prefix AND suffix, and both regexp.

I'm using borg 1.2.0 from compiled github releases, "linuxold" version.

Originally posted by @knutov in https://github.com/borgbackup/borg/discussions/6337#discussioncomment-2452748

knutov avatar Mar 29 '22 00:03 knutov

Is that a regression / did that work with 1.1.x?

ThomasWaldmann avatar Mar 29 '22 12:03 ThomasWaldmann

Just checked now, with 1.1.17 it also does not work.

knutov avatar Mar 29 '22 12:03 knutov

manifest.Archives.list only supports shell pattern style. regex is not implemented there (yet?).

Guess it would be easy to implement via borg.patterns.parse_pattern.

Just the default needs to stay as is for compatibility.

ThomasWaldmann avatar May 09 '22 02:05 ThomasWaldmann

@knutov have a look at PR #7028.

ThomasWaldmann avatar Sep 16 '22 12:09 ThomasWaldmann

@ThomasWaldmann looks great! Will it be released in 1.2 branch?

knutov avatar Sep 16 '22 21:09 knutov

Guess I rather won't backport that:

  • widespread changes
  • changing the option name would break scripts
  • master patches likely can't be cherry-picked easily due to master now being formatted by black and due to the code being split into many modules

ThomasWaldmann avatar Sep 17 '22 11:09 ThomasWaldmann

If somebody else wants to do a backport to 1.2-maint branch, I guess it would be acceptable if:

  • all the renaming i did in master branch is not done (== keep glob func param, keep --glob-archives option name)
  • keep the default behaviour of using shell patterns (no prefix means same as sh: prefix), so no existing scripts break
  • use other code and tests similar as in PR #7028

ThomasWaldmann avatar Sep 17 '22 17:09 ThomasWaldmann