--keep-within feature explanation

I just came across the new --keep-within feature which is a great addition. Unfortunately the documentation is not clear to me. Don’t know if my english is too poor or if I need more coffee. :face_with_raised_eyebrow:

--keep-within duration keep all snapshots which have been made within the duration of the latest snapshot.

What exactly does “duration of the latest snapshot” mean?

Additionally it is not clear to me which parameters take precedence over another when they are combined. If I make weekly snapshots and use --keep-last 10 --keep-within 1m, which option wins? I assume restic keeps 10 snapshots to be on the safe side, but I think this should be stated somewhere in the documentation.

The bad docs are my fault, sorry. Keep within will keep all snapshots within the duration given relative to the latest snapshots timestamp.

So if you give a duration of 12m, and your last snapshot was made 1m ago, it will keep all snapshots within 13 months of now. The reason it’s since the latest snapshot is to ensure you have a window of snapshots for that long which you can restore, rather than deleting snapshots over time just because time is passing.

Thanks for the explanation, it does now make sense to me. Can you shed some light on the 2nd question too?

Both are applied, which means that all snapshots are kept for which at least one of the options decide to keep the snapshot.

The manual needs more examples. @matt would you like to do a PR sometime?

I think it just needs an explanation that the filters are “ORed” together, not “ANDed”, and that they aim to include as many snapshots as possible, not exclude as many as possible. Right?

1 Like

That’s what I thought, thanks!

IMHO this should suffice.

Yep, that’s correct.

1 Like

Great. I’ll try to find a moment to make that update.