borg icon indicating copy to clipboard operation
borg copied to clipboard

Prune: Keep x per day / week / month, no matter how many in total

Open TheCataliasTNT2k opened this issue 11 months ago • 6 comments

Have you checked borgbackup docs, FAQ, and open GitHub issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

ISSUE

System information. For client/server mode post info for both machines.

Your borg version (borg -V)

borg 1.2.8

Operating system (distribution) and version

Linux Mint 20

How much data is handled by borg?

389G

Describe the problem you're observing.

My drive is now full, and I need to remove (prune) old backups.

However, I do not want to only keep the last 14 days, but two backups per week, no matter, how many that would be. As far, as I understand the documentation, this is currently not possible. Would it be possible to implement that?

TheCataliasTNT2k avatar Jan 16 '25 22:01 TheCataliasTNT2k

To free space, you need to run prune and compact.

Don't forget compact, only that will free space (for borg >= 1.2.0).

borg has all sorts of pruning, from secondly to yearly, but there is no "keep 2 per week".

E.g. you could:

  • keep everything within 3 days
  • keep 60 daily backups
  • keep 26 weekly backups
  • keep 36 monthly backups
  • keep 10 yearly backups

Note that keeping backups that are "close" to each other (on the time scale) does not need much space. The more far apart they are, the bigger the differences / the deduplicated size.

ThomasWaldmann avatar Jan 16 '25 22:01 ThomasWaldmann

Would it be possible, to implement that?

In my case, borg can not deduplicate everything, because of InfluxDB, which stores a ton of data every day.

So it would make sense, to remove half of the backups, but not "one half in one chunk" more like "every second backup".

TheCataliasTNT2k avatar Jan 16 '25 23:01 TheCataliasTNT2k

A lot is "possible", just needs a developer investing time into this. :-)

Would likely make pruning docs / code a bit more complex than it already is though.

ThomasWaldmann avatar Jan 21 '25 17:01 ThomasWaldmann

I deleted the archives manually, by

  • running borg list
  • using python do get every second backup
  • using python again, to put the result into borg delete PATH::<archive> one by one
  • copying all commands created in bash and waiting

I had 902 archives, I ignored January 25 and December 24. The repo was ~400 GB before and is now ~300 GB.

TheCataliasTNT2k avatar Jan 26 '25 16:01 TheCataliasTNT2k

https://borgbackup.readthedocs.io/en/stable/usage/delete.html

Guess you could also invoke borg delete REPO arch1 arch2 ... archN (up to the limits imposed by the OS on the cmdline length) to get a bit better performance.

Run borg compact once after you have deleted all the desired archives.

ThomasWaldmann avatar Jan 26 '25 17:01 ThomasWaldmann

I did compact, yes. Did not see that borg delete accepts multiple archives, thank you!

TheCataliasTNT2k avatar Jan 26 '25 17:01 TheCataliasTNT2k