--group-by option for snapshots command


#1

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:


#2

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.


#3

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

I’m looking to GROUP by the tags


#4

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?


#5

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: https://github.com/restic/restic/issues/2037


#6

So you want to sort by tag?


#7

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


#8

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


#9

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


#10

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


#11

Yes, that’s a workaround for now:

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

#12

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

It appears so.


#13

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.


#14

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


#15

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