Restic forget - keep last 7 snapshots regardless of the path

I’m using the script to backup openwrt configuration as a file with date, e.g. /openwrt_192.168.8.1-20220225_205201.tgz. The issue I’m having is that restic forget --keep-last 7 does not work as expected, because each path is different, so no snapshot is forgotten. My workaround for this is:

restic forget --prune $(restic snapshots --no-lock --quiet --json | jq '.[] | .short_id' | tac | sed '1,7 d' | tac | sed 's/\"//g')

I think what you’re looking for -g argument on forget command. By default it includes paths, you might want to try with -g host.

You’re right, grouping by the host is more elegant solution. :+1: