borgmatic prune unexpectedly selects all hostnames on default settings #753
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I noticed a lot of my backups were pruned automatically recently, including from devices I haven't updated recently. The recent deprecation of
prefix
in the configuration file indicates thatmatch_archives
andarchive_name_format
should be used instead. The default example config states:Moreover, it also states:
However, in the implementation of
make_prune_flags
the following happens:From debugging this with
pudb
, at thatelse
statementconfig.get('archive_name_format')
returns an empty string, which goes against my understanding of what the configuration file claims. This then leads themake_match_archives_flag
method to do:before it tries to derive match_archives. As a result, all archives, regardless of their hostname, are considered for pruning.
This may also affect other callers of
make_match_archives_flags
, as I don't see any other functions implement a default for 'archive_name_format', but I did not investigate in detail.Steps to reproduce
match_archives
andarchive_name_format
left unspecified on the different hosts.borgmatic prune --list
Actual behavior
Expected behavior
Other notes / implementation ideas
A workaround is to specify
match_archives
to besh:{hostname}-*
explicitly. Looking at the source code, it might also work ifarchive_name_format
is explicitly defined, but I did not try this.This does not happen in 1.7.7, but I think that's because
prefix
hadn't been deprecated yet.The fix might be to make sure that if
archive_name_format
is empty, that a default is assigned.borgmatic version
1.8.2
borgmatic installation method
emerge borgmatic
Borg version
borg 1.2.6
Python version
Python 3.11.5
Database version (if applicable)
No response
Operating system and version
NAME=Gentoo ID=gentoo PRETTY_NAME="Gentoo Linux" ANSI_COLOR="1;32" HOME_URL="https://www.gentoo.org/" SUPPORT_URL="https://www.gentoo.org/support/" BUG_REPORT_URL="https://bugs.gentoo.org/" VERSION_ID="2.14"
And yes, apparently the grand purge of all of my older backups took place sometime around March of this year, I just didn't notice it until now (at least according to data from my off-site backup location). From my understanding of borg, those old prunes are gone now, right? I haven't suffered data loss so it's not a huge issue, but boy am I glad I caught this issue now and not after actually needing all of the archives intact.
I did a bit more testing, and I can confirm that setting
archive_name_format
explicitly to what's supposed to be the default value also leads to correct behavior.Thanks for taking the time to file this! Right now the documented
archive_name_format
default is only used to name the archive during archive creation (borgmatic create
), and the documentation / schema comments are misleading in suggesting that the default applies to other actions as well. I agree with you that it would make more sense to also apply the default forprune
and other actions, specifically when deriving the match archives flags.That's unfortunately correct!
This is implemented in main and will be part of the next release. Thanks again for highlighting the need.
You should be aware though of this ticket: #748. If implemented as currently described, it would probably break your use case because it would start treating
{hostname}
in the archive name format as*
for purposes of filtering archives. I'm open to ideas on that ticket for how to solve the ask without breaking your use case!This has been released as part of borgmatic 1.8.3!