--group-by option for snapshots command

it would be great to have the --group-by option available for the snapshots command as well as the forget command. It makes it much easier to see the sets of backups marked with tags.

restic snapshots -g tags

Thoughts Alex? :slight_smile:

If you want to see snapshots only for a particular tag: restic snapshots --tag <tagname> will do the trick. Unless you’re trying to sort by tag.

That’s not the functionality I’m looking for matt.

I’m looking to GROUP by the tags

Hm, not sure I understand correctly. For feature requests, it’d be great if you could fill out a new issue here: https://github.com/restic/restic/issues/new?template=Feature.md

Can you maybe manually reformat the output of restic snapshots with your (proposed) new option? What should it do exactly?

Can you maybe manually reformat the output of restic snapshots with your (proposed) new option? What should it do exactly?

Similar grouped output as you see when you run restic forget -g tags

snapshots for (tags [monthly]):
      ...
snapshots for (tags [daily]):
     ...

Feature request: --group-by option for snapshots command · Issue #2037 · restic/restic · GitHub

1 Like

So you want to sort by tag?

Ah, I get it now. The idea is to still display all snapshots, but grouped by e.g. the tags. The list output would then be almost the same as restic forget --dry-run --keep forever --group-by tags

1 Like

I see. I guess I don’t understand the difference between sorting and grouping, in that case.

Maybe we’re just talking about the same thing :wink:

Matt: In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order. For example, sorting in alphabetical order, A-Z, or numerical 0-9.

Grouping on the other hand is arranging the data by sets.

Example:

Sorting 0,2,3,1,5,6,7,8,9 by ascending order:
0,1,2,3,4,5,6,7,8,9

Grouping 0…9 by even/odd results in two sets:
0,2,4,6,8
1,3,5,7,9

Yes, that’s a workaround for now:

restic forget --dry-run --keep-within 99y --group-by tags

And yet, if you sort by tag, they are also grouped by tag. :slight_smile:

It appears so.

1 Like

If it is not too much to ask, maybe this could be implemented for hosts and paths too, so you can list snapshots by tags, hosts or paths.

My suggestion as for to work exactly like the group-by for forget, so that would include tags, hosts and paths :relaxed:

OK! Sorry for the dumb suggestion, I didn’t find it obvious when I read the thread. :man_facepalming: