I would like to keep user snapshots for the last one month only (now is Jan 2021).
There are many users using our backup solution. For users who actively creating backup, this should be easily done with --keep-within 1m --group-by ''. But for inactive one, its quite tricky to get this done right.
Restic is always using the latest snapshot as a reference. In your example above all 4 snapshots would be kept as 2f24f1a1 is the latest snapshot and the other 3 snapshots are within the timespan of 1 month (2020-09-20 until 2020-10-20). Unless you have something different in mind, restic is doing the ‘right thing’ by default.
PS: You can test your policies by using the --dry-run flag.
OK, I just read OP’s post again. I initially assumed that 1 month of backups should be kept no matter how old they are. But if the intention is to delete everything older than 1 month (and leave inactive users with no backup), then there is no way to do this with restic that I know of.
One “hacky” possibility would be to just do a “fake” backup before e.g. of an empty dir (and get the snapshot ID) , use your proposed --keep-within 1m --group-by '' and then run forget a second time to explicitly remove that “fake” snapshot.
For a proper solution, you should run restic snapshots --json, parse the output by some script which determines the snpahot IDs to forget and run forget with those IDs.