I’ve been pondering this on and off and have finally figured it out, alongside jq
. In my case I want to select snapshots by the tag “quick”, and group by tag only. This jq
command walks through the snapshots of all groups, maps the “id” field to an array, and joins each result with a space, which formats it into a string which restic diff
can process.
restic diff --no-lock $(restic snapshots --no-lock --json --latest 2 --group-by tag --tag quick | jq --raw-output '(.[].snapshots | map(.id) | join(" "))')
If you’re not changing the default grouping, this command omits walking through the groups thus. Using --tag
is at your discretion.
restic diff --no-lock $(restic snapshots --no-lock --json --latest 2 --tag quick|jq --raw-output '(map(.id) | join(" "))')