Don't pass the --stats flag to borg prune when using Borg 2.0 #1010
Labels
No labels
blocked
breaking
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#1010
Loading…
Reference in a new issue
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
When using Borg 2.0 and running
borgmaticwith--stats(which implicitly runsprune), the user receives an error because Borg 2.0 no longer supportsprune --stats: https://borgbackup.readthedocs.io/en/latest/usage/prune.htmlIt appears to have been removed in this commit, which suggests using compact for stats instead:
git.zknt.org/mirror/borg@4c052cd65d (diff-a08f625915)Also see: https://github.com/borgmatic-collective/docker-borgmatic/issues/395
Steps to reproduce
Use Borg 2.0 and run
borgmatic --statsor a variant thereof.Actual behavior
Expected behavior
borgmatic runs the default actions and doesn't pass
--statstoprune(when using Borg 2).Other notes / implementation ideas
Probably the thing to do here is add a feature toggle such that
--statsgets passed topruneon Borg 1 but not 2.It'd also be a good idea to update the CLI docs to say "Borg 1 only" on
prune --stats.borgmatic version
1.9.12
borgmatic installation method
No response
Borg version
2.0.0.b13
Python version
No response
Database version (if applicable)
No response
Operating system and version
No response
Additional Info :
Please Pass --stats to
borg compactin-caseborg compactallows it. (I am a little confused here whether it supports it or not since at one place it is mentioned it supports it but in the official documents it is not there.)Yeah, unfortunately it doesn't appear that Borg 2 implements
compact --stats: https://borgbackup.readthedocs.io/en/2.0.0b14/usage/compact.html ... That changelog might just be indicating that compact displays some stats by default without actually having a formal--statsflag. For instance, these "stats" are what I get when running Borg 2 just withcompact --info(equivalent to borgmatic's--verbosity 1):I want to work on this issue.
Awesome, please have a look at the docs on how to get started with development! It might also save you time if you wanted to outline your approach to the ticket here to get feedback before you start writing code. But it's also small enough that you could probably just submit a PR if you don't mind the risk of re-work.
One thing that may be useful for this particular ticket is the existing feature flag support. That's how borgmatic typically provides different behavior for different versions of Borg. And here's an example of that in action.
Let me know if you have any questions!
Yes I have few things to say:
(('--stats',) if prune_arguments.stats and not dry_run and borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.PRUNE_STATS, local_borg_version) else ())That makes sense to me! For point number one though, I think you can simplify even further. Rather than introducing the concept of a "feature removal", you can continue using
FEATURE_TO_MINIMUM_BORG_VERSIONand add an entry to it called something likeFeature.STATLESS_PRUNEorFeature.NO_PRUNE_STATSor whatever. The idea being that a Borg feature removal is really a feature change or addition just like anything else. Then you wouldn't have to updateavailable()either.Also, don't forget the automated tests piece of this (I'm think mostly for point number two), which should hopefully be pretty straight-forward. Thank you!
Is it about adding
flexmock(module.feature).should_receive('available').with_args( module.feature.Feature.NO_PRUNE_STATS, '1.2.3' ).and_return(True/False)to all tests(in test_prune.py)(True/False based on test) with stats such as.Or is it required to write new tests? Please correct me if I am wrong(I am new to testing)
Adding that mock to the existing tests seems like a good idea, but you might need to add a single new test—since presumably the existing tests wouldn't vary the
available(NO_PRUNE_STATS, ...)return value. For instance, the mock you add to all the existing tests might all returnTrue, and then you could just add one more test that has theFalsereturn value mock and the corresponding expectation. (Or the other way around.)Released in borgmatic 2.0.0!