brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: borg prune --list --dry-run shows what a retention rule would delete

Linux
~/tips/tip-backup-borg-prune-dry-run-list

borg prune -v --list --dry-run --keep-daily=7 --keep-weekly=4 /path/to/repo

Previews which borg archives a prune rule keeps and removes, without changing the repository.

A wrong keep rule in borg prune removes archives you wanted. The prune command can show its decision before it does anything, which is how I would test every new rule.

borg prune -v --list --dry-run --keep-daily=7 --keep-weekly=4 /path/to/repo

This is the example from the Borg docs: keep 7 end-of-day archives and 4 additional end-of-week archives, and do a dry run without deleting anything. --list prints every archive together with whether prune keeps it or prunes it, and --dry-run means the repository is not changed.

When the list is what you wanted, run the same command without --dry-run. If several machines or jobs write into one repository, limit the rule to one of them by archive name, as the docs do with the hostname:

borg prune -v --list --keep-daily=7 --keep-weekly=4 --glob-archives='{hostname}-*' /path/to/repo

This only works when your archive names follow a pattern, which is a good reason to name archives {hostname}-{now} from the start. Without a pattern, a rule meant for the laptop can delete the server’s archives.

Other keep options exist for different shapes: --keep-within for a time interval, --keep-monthly, --keep-yearly, and --keep-last. A value of -1 keeps one archive for every period, for example --keep-monthly=-1 keeps an end-of-month archive for every month.

Remember that prune only deletes the archives. The docs state it plainly: repository space is not freed until you run borg compact. So a smaller disk usage is not the sign that prune worked. Once the real prune has run, the deleted archives are gone, even while the files still take up space.

Further reading: Borg docs: borg prune

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link