Let’s say I just configured restic on a new (Linux) server, and I run a first backup for just /etc path, just to test everything is ok with remote repository.
After this, I create my cron job to run restic every day, with some set of directories, eg.
/etc
/home
/var/backups
After a while, my repository is populated with several snapshots; the first one has only /etc (my very first restic run), and the following ones have /etc, /home/ and /var/backups.
At this point, if I run restic forget –keep-daily 14, I notice that the very first snapshot (with only /etc is never deleted, I need to manually delete that snapshot by using his id.
If there are not enough snapshots to keep one for each duration related --keep-{within-,}* option, the oldest snapshot is kept additionally and marked as oldest in the output (e.g. oldest hourly snapshot).
I expect that this section of the manual is relevant here:
When forget is run with a policy, restic first loads the list of all snapshots and groups them by their host name and paths. The grouping options can be set with --group-by, e.g. using --group-by paths,tags to instead group snapshots by paths and tags. The policy is then applied to each group of snapshots individually. This is a safety feature to prevent accidental removal of unrelated backup sets. To disable grouping and apply the policy to all snapshots regardless of their host, paths and tags, use --group-by '' (that is, an empty value to --group-by).
Basically, restic is seeing the snapshot with just /etc as a different group to the one with /etc, /home and /var/backups
And thus is apply “keep last 14” to it, and it’s the one so it’s one of the 14.