Deleting all snapshots older than a certain timestamp

Hey everyone – I was just wondering if there is a way to remove snapshots older than a certain timestamp from a repository. And prune the unreferenced data. Basically restic forget --prune but for all snapshots older than, say, 12 months.

Is there a clever use of existing policy flags (--keep-*) that can accomplish this? I don’t need to limit how many snapshots remain, I just want to get rid of all the old ones and prune the data that only the old, removed snapshots referenced.

My use case is keeping deleted files in the backup for a certain timeframe, before they are removed by a script that runs restic forget --prune regularly. If this isn’t currently supported, I will submit a PR for it. (It doesn’t seem like a great fit for restic.ExpirePolicy though, which limits the number of remaining snapshots.)


(Edit: This wasn’t hard to implement, so I made a PR: – but if this was already possible, just let me know!)

I don’t think there is a smart way to do this with the use of --keep-* flags unless you are making periodical backups of a server and definitely know how many backups you will have within 1 year.

Okay. No problem then, hopefully my PR will take care of this use case!