Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add borg prune --keep-all #6656

Open
PhrozenByte opened this issue Apr 29, 2022 · 2 comments · May be fixed by #7462
Open

Add borg prune --keep-all #6656

PhrozenByte opened this issue Apr 29, 2022 · 2 comments · May be fixed by #7462

Comments

@PhrozenByte
Copy link
Contributor

PhrozenByte commented Apr 29, 2022

/kind enhancement

I have created a Borg repo that I use for manual backups only. Since I don't have a retention policy for this Borg repo either, I don't run borg prune at the moment. However, I just noticed that borg prune has another feature besides removing old archives according to a retention policy: removing old checkpoints.

Also, prune automatically removes checkpoint archives (incomplete archives left behind by interrupted backup runs) except if the checkpoint is the latest archive (and thus still needed). Checkpoint archives are not considered when comparing archive counts against the retention limits (--keep-X).

Since checkpoints aren't listed by borg list by default, quite a lot of checkpoints can accumulate before one notices it.

Right now I can't easily remove just old checkpoints from a Borg repo; passing no --keep-* option to borg prune yields the error:

At least one of the "keep-within", "keep-last", "keep-secondly", "keep-minutely", "keep-hourly", "keep-daily", "keep-weekly", "keep-monthly" or "keep-yearly" settings must be specified.

One can work around this error by using a very large number for --keep-last, e.g. --keep-last 1000000000. Another solution is to mimic borg prune's behaviour by using borg list --consider-checkpoints, a little sed magic and borg delete.

IMO this is a reasonable use case and Borg should support it without taking such workarounds.

Thus I'd like to suggest adding a --keep-all option to borg prune, specifically telling borg prune not to remove any actual archive, but just old checkpoints as explained before. Passing --keep-all with any other --keep-* option should probably thrown an error.

@ThomasWaldmann
Copy link
Member

Considering that the default is to erase anything that is not explicitly kept, changing the behaviour for giving no --keep-* option does not sound like a good idea (because that would mean "erase all").

Yeah, we could add a --keep-all as an alias for --keep-latest <many_or_infinite>, but that's just cosmetics.

BTW, way more important is that you still use the right --prefix so prune stays inside the right backup set / sequence when determining the latest (checkpoint) archive of that set / sequence.

@PhrozenByte
Copy link
Contributor Author

PhrozenByte commented Apr 29, 2022

Considering that the default is to erase anything that is not explicitly kept, changing the behaviour for giving no --keep-* option does not sound like a good idea (because that would mean "erase all").

Just to clarify, I didn't mean to suggest that. My description might have given a false impression about that, sorry for the misunderstanding.

Yeah, we could add a --keep-all as an alias for --keep-latest <many_or_infinite>, but that's just cosmetics.

Indeed. I chose to use --keep-last 1000000000 in the meantime, adding --keep-all as an alias for --keep-last <infinite> would be great 👍

BTW, way more important is that you still use the right --prefix so prune stays inside the right backup set / sequence when determining the latest (checkpoint) archive of that set / sequence.

Thanks for the heads up! Since I use a distinct Borg repo for my manual backups it doesn't really apply to my personal use case, but you're right, for Borg repos with multiple backup sets it definitely makes a huge difference.

#edit: It's --keep-last, not --keep-latest, my bad 🙈

@ThomasWaldmann ThomasWaldmann added this to the 1.2.x milestone May 10, 2022
Michael-Girma pushed a commit to Michael-Girma/borg that referenced this issue Mar 22, 2023
Michael-Girma pushed a commit to Michael-Girma/borg that referenced this issue Mar 22, 2023
@ThomasWaldmann ThomasWaldmann modified the milestones: 1.2.x, 1.4.0a1 Dec 23, 2023
@ThomasWaldmann ThomasWaldmann modified the milestones: 1.4.0a1, 1.4.0x Jan 1, 2024
@ThomasWaldmann ThomasWaldmann modified the milestones: 1.4.0b1, 1.4.0b2 Jan 20, 2024
@ThomasWaldmann ThomasWaldmann modified the milestones: 1.4.0b2, 1.4.x Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants