[solved] Destroy zfs snapshots

I have a question on zfs and thought as many use proxmox here and some may have good knowledge on zfs maybe someone has an easy answer for me. I know that there is the -r switch for destroying snapshots including its children, meaning the following snapshots. What I’d like to know, if there is an easy way to delete a snapshot and with it every snapshot taken before the one easily?

I have seen that it is not possible to use * for ex. for deleting all snapshots named vm-disk-xy@snapshot2011* for removing vm-disk-xy@snapshot2011[1-31xyz] so right now I am issuing a destroy command for each individual snapshot. Is there a switch or rexexp. that could be used to ease my life ? :slight_smile:

Unfortunately, there is not command for this. If you want to destroy all snapshots which names begin with 2020-021, you have to use shell utilities like e.g.

zfs list -t snapshot -H -o name | grep 2021-01 | xargs -n1 zfs destroy

EDIT: added -H -o name as options

3 Likes

Perfect, Carsten, as always - thanks a lot for your help :+1: