borg icon indicating copy to clipboard operation
borg copied to clipboard

Extend --glob-archives to support regex

Open timwsuqld opened this issue 5 years ago • 6 comments

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

Yes

Is this a BUG / ISSUE report or a QUESTION?

Feature

System information. For client/server mode post info for both machines.

Your borg version (borg -V).

$ borg -V borg 1.1.9

Operating system (distribution) and version.

Ubuntu 18.04

How much data is handled by borg?

3+TB

Full borg commandline that lead to the problem (leave away excludes and passwords)

borgbackup prune --stats --list --dry-run --keep-last 4 --keep-daily 14 --glob-archives 're:^gcs-mariadb-1-1-[0-9]*$' /backups/borg/linux-1

Describe the problem you're observing.

We have backups in the same archive that share a common prefix, and need to apply to prune in a more controlled fashion. Allow RE as part of glob-archives would allow us to give the slightly more complicated Regex to ensure the filtering works.

Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.

Yes. Take backups that have a shared common prefix, and then attempt to prune causing excess prunning.

server-1-123456789
server-1-987654321
server-1-extra_disk-123456789
server-1-extra_disk-987654321

Attempt to prune with prefix server-1 will prune the backups for server-1-extra_disk as well. However if we can filter on ^server-1-[0-9]*$ then the issue goes away

timwsuqld avatar Mar 15 '19 00:03 timwsuqld

Easy workaround: use unique prefixes.

This is also the reason why the prefix does not only contain hostname, but hostname- in the examples.

ThomasWaldmann avatar Mar 15 '19 12:03 ThomasWaldmann

@ThomasWaldmann I'm aware that unique prefixes would be ideal. In this case, the prefixes are coming from an external system, which used a "unique" prefix that ended up being a prefix of existing prefixes. I'm working on fixing the external system, however it seems a little odd that we have all the power of patterns, but only allow sh matching for glob archives.

Looking through the source code, it appears that we once only supported prefix matching, and then moved to that using the sh glob matching instead when we added globbing support. Maybe just supporting all the pattern would be convenient?

I'm sure there are other use cases where having the power of regex would be useful in matching specific archives as well.

timwsuqld avatar Mar 17 '19 22:03 timwsuqld

If you can make a small PR that is compatible with previous behavior, feel free to do so.

ThomasWaldmann avatar Mar 17 '19 22:03 ThomasWaldmann

Also: not 100% certain, but it seems like --glob-archives doesn't support {hostname}. If it doesn't, shall I open a separate request for this? Or would that be useful?

fbicknel avatar Apr 03 '19 20:04 fbicknel

@fbicknel separate issue.

ThomasWaldmann avatar Apr 03 '19 21:04 ThomasWaldmann

see #7028.

ThomasWaldmann avatar Sep 17 '22 12:09 ThomasWaldmann