borg
borg copied to clipboard
Extend --glob-archives to support regex
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
Easy workaround: use unique prefixes.
This is also the reason why the prefix does not only contain hostname
, but hostname-
in the examples.
@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.
If you can make a small PR that is compatible with previous behavior, feel free to do so.
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 separate issue.
see #7028.