Many borgmatic commands do not return any information #748
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#748
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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
trying to run commands like borgmatic info or borgmatic list
Steps to reproduce
Actual behavior
running borgmatic info returns no information.
weirdly enough, borgmatic info with --archive latest works fine. running
borg info
manually also works fine.Expected behavior
should get output but get nothing.
root@ash-bm-1142-ey2:~# borgmatic info
borgbase: Displaying archive summary information
Other notes / implementation ideas
did the archive name fetching system break on newer borg versions?
borgmatic version
1.8.2
borgmatic installation method
pip
Borg version
1.2.4
Python version
3.10.12
Database version (if applicable)
No response
Operating system and version
Ubuntu 22.04.3
Many borgmatic do not return any informationto Many borgmatic commands do not return any informationUpdate (luckily you are opensource, yay!):
the code looks for match_archives, but that breaks if the hostname is changed (which in my case happened because we were restoring on a new install). Setting match_archives to '*' fixes the issue.
I would personally think it would be better to default match_archives to * instead of having it depend on the archive_name_format or hostname so this does not scare people trying to do restores out. I am not sure if there are any workflows that this would break, but it is something that i'd consider changing.
Thanks for taking the time to file this one—and debug it yourself! 😄 The current
match_archives
filtering behavior is actually designed to support a common use case where a user has multiple borgmatic configuration files, each with a differentarchive_name_format
. For that, deriving thematch_archives
value from thearchive_name_format
ensures that any givenborgmatic info
orlist
command doesn't output the same archives multiple times, because each config file's output gets filtered down to just its own archives. So changing thematch_archives
default to*
would break that use case among others. You can read more about this automatic archive filtering here: https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#archive-filteringHowever I can see how this behavior is kind of surprising and obnoxious for your use case, where you've only got a single configuration file and you just wanted to restore your archives to a different host. So one idea is to try to detect this case and display a warning to the user. I'm not sure how feasible this is, since borgmatic doesn't normally parse Borg output, but maybe it could do a separate JSON
list
/info
first and see if there are any archives found matching the current filtering. If not, borgmatic could display a prominent warning that says something like:No matching archives found. Maybe some archive filtering is going on? Try setting --match-archives * if you want to see all archives.
And/or maybe this could just be documented around.
Thoughts?
A warning like that is a good idea. I'm not sure how you derive match-archives from archive_name_format, but another idea is to filter out the hostname like you do with the timestamp and only match hardcoded (non-variable) strings in match-archives? In that way a given config file would have a deterministic output independent of the host, but you can still separate your backups by adding a prefix. Parsing the hostname as ephemeral would also not break your usecase of having multiple files.
I like that idea as a solution. It stretches the definition of "ephemeral data placeholders" a bit, but presumably auto-converting
{hostname}
inarchive_name_format
to*
inmatch_archives
wouldn't break the multiple-config use case, because they should all have the same hostname if they're on the same host! In fact, if making this change I would probably change it so all{placeholder}
s get replaced with*
.So I discovered a problem with this solution: It breaks the use case in #753, conveniently filed just recently. Specifically, the user in #753 wanted borgmatic's default
archive_name_format
of{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}
to be applied to filter archives (as{hostname}-*
), so only the archives for a single hostname get pruned on a particular host. Which seemed like a totally reasonable expectation to me.But if this ticket gets implemented as described above, the archive filter will become
*-*
instead of{hostname}-*
—and pruning will no longer be host-specific. So that makes me think maybe the changes to how archive filtering is derived won't work, and maybe we're back to the warning-based solution. Unless there's some other solution I'm missing...As the reporter for #753 who already lost old archives to a prune that was effectively matching all (due to the issue reported in #753), I would prefer that prune's filter not be overly aggressive by default. Prior to 1.8 at some point, borgmatic leveraged the
prefix
option to control the filtering of pruning, and ifarchive_name_format
is its replacement, I'd hope its semantics are somewhat similar-- else you end up with data loss as what happened to me.I've seen other software report warnings in cases like this one. A very rough pseudocode for logic for the warnings might be:
This way if there truly is nothing in the backup, there's no warning, but otherwise, it's at least a notice to let the user know that there are other archives that the current filter option does not cover. And if the user is explicitly asking for a non-default filter option, maybe don't print the warning, I think.
That makes sense to me. Thanks for weighing in! Also note that
match_archives
is more of the replacement forprefix
. Butarchive_name_format
is used to auto-populatematch_archives
if its value is not set.This warning has been implemented in main for the "rlist" and "info" actions and will be part of the next release. The only caveat is that it doesn't check that all archive data is not empty as suggested.
Here's an example of the warning in action:
Released in borgmatic 1.8.4!