Pruning rewrite snapshots

I have a bunch of snapshots with the tag rewrite. Initially, I thought “ah, those snapshots are rewritten and have superseded some other one”.

However, I now noticed that these are snapshots that are rewritten and superseded by some other one.
It seems to me that I am “carrying around things” that I don’t need.

However, how can I tell if it is safe to remove them (and the underlying data ofc)?
There have been a number of check / check --read-data that have ran against them through the course of those snapshots living (I guess maybe even a year).

… However, I don’t know how rewrite and check / check --read-data: Does it ignore them completely - both snapshots and “data unique to them”, or it is possible that data pruned from the rewrite snapshots might be referenced by non-rewrite snapshots?

Disclaimer: I am confusing git with restic sometimes, some of my “misunderstanding” might be stemming from that.

The snapshots with the rewrite tag are those that a newly created by the rewrite command. The original snapshots are not modified by the rewrite command (--forget deletes them though).

rewrite just works on the snapshots you tell it to process, the rewrite tag has no special meaning there. check simply processes all snapshots in the repository; tags are irrelevant for it.

Oh. So, it’s actually the opposite? :sweat: I need to delete the non-rewrite snapshots to remove the files that rewrite “forgot”?

So, is there a possibility that pruning the old data will leave the rest with “missing references”?

Exactly. It’s also rather simple to verify experimentally: Just create a small snapshot and use rewrite to drop some files. Then take a look at the old and new snapshot using ls.

No. prune never deletes data that is still in use by any snapshot. Unlike traditional backup software, each snapshot contains references to all files. As restic deduplicates the stored data, this still yields rather compact snapshots.

yeah - maybe I’ll try to compare “some” snapshots to understand which one is “the latest”.

… Since I thought everything in snapshot is immutable, including attached tags (therefore, the old snapshots CANNOT be added tags, since that will change their sha1).

But thank you for your verbose explanation :upside_down_face:

You’re right it is not possible to modify snapshots without changing their snapshot ID. restic tag creates new snapshots and deletes the old ones.