[Borgbackup] Prune too much?

Thomas Waldmann tw at waldmann-edv.de
Wed Apr 27 05:43:32 EDT 2022


> It prunes the archives like this:
> borg prune --stats --list -w 7 -m 7 -y 1 "$backup"
> 
> Now there's one repository for a partition on a hard drive that is now
> missing, has been for a while, but it took me a while to catch up and
> remove it from the array of backup repositories on my script.
> 
> I now noticed that of 15 archives in the repo, only 1 (the oldest)
> contains actual data, all others are empty.

borg prune only looks at the archives' timestamps, it does not look at 
the archives' content (nor could it know whether the content is what you 
want it to be).

> The oldest & only archive containing data is 1.5y old; I'm not 100%
> sure, but I think I still used the partition in question after that,
> and if I did I definitely added new files.

I am not aware of bugs relating to the application of keep rules in borg 
prune.

But sometimes is a bit difficult to see how it applied the rules and why 
the outcome is like it is. So there were users thinking it does not work 
correctly. But when analysing the reported cases, it always was found to 
work as designed / as documented.

In borg 1.2, the output of borg prune was improved to also tell the rule 
that kept an archive to make it easier to see how it works and why it 
keeps a specific archive. Try --list.

> I am slightly worried: could 'borg prune' ever result in a situation
> where I'm left with only empty archives? Or where it prunes the most
> recently added data?

If the rules only keep archives that do not have the desired content, 
that is possible. It does not look at the content. Nor can it know 
what's the desired content.


IIRC, we added some related error signalling code though:

If you give a non-existing path to borg create, it will give an error 
msg and terminate with rc 2 (but it WILL create an archive containing 
all existing files other files, if any).

If an include pattern never matched, it will give a warning msg and 
terminate with rc 1.


General hints:

- check borg output and return codes

- maybe use borg create --list (maybe with or without --filter=AME) for 
better awareness about what will be in the created archive


More information about the Borgbackup mailing list