restic 0.19.1 compiled with go1.26.5 on darwin/arm64
Hi,
I have a use case where I want to keep all snapshots with a particular tag for N days after they were made, but after that I don’t care about them at all. They can all be removed; however I know that restic won’t remove all snapshots, so keeping “the latest that is older than N days” is fine. Assuming a daily run of restic forget, is there any restic retention policy that would accomplish this, or do I need something like a Python script to explicitly delete snapshots by ID?
Here is the use case, in case that helps. I make three snapshots a day of my home directory, using a scheduler (launchd on macOS). These are tagged with plan:full. However, from time to time, I do some intensive processing of photographs using apps like Photoshop. During this intensive period, I want to make more frequent snapshots if needed. This would let me “roll back” to an earlier version of my work in case I don’t like my changes. So, what I do is run a daemon script that runs fswatch on my photograph work directories. If fswatch detects a change within a latency period (I have it set to 20 minutes), the script fires a restic command that backs up just my work directories, using a special tag plan:demand.
Think of it as something like git for my photographic work, but unlike git, I only need a short history, say 5 days. If I’m satisfied with my processing decisions for 5 days, it’s highly unlikely that I will need to revisit them. Meanwhile, the daily full plan has snapshots of the image, so I would like to delete all snapshots with the tag plan:demand that are older than 5 days. I don’t want to clutter the repo with tons of snapshots (restic seems to slow down on prune and check operations quite a bit when there are hundreds of snapshots). Plus, the many intermediate snapshots add unnecessary storage space to the repo.
The problem I’m facing is that restic forget --keep* options all use the latest snapshot as the referent, not today’s date. So if I use restic forget --keep-within 5d, it won’t do what I want.
I’m familiar with Python scripting, so I could write a Python script that issues restic forget commands with explicit snapshot IDs, but I want to make sure that’s actually needed.
Thank you.