[solved] Destroy zfs snapshots

Elleni

Active Member
Jul 6, 2020
145
6
38
51
I have a question on zfs and thought as many use zfs 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-31_hhmm] so right now I am issuing a destroy command for each individual dayly snapshot - so about 30 destroy commands per vm to delete a months snapshots. Is there a switch or rexexp. that could be used to ease my life ?
 
Last edited:
Hi,
the man page is your friend man zfs (or man zfs-destroy if you're running a new enough version):

Code:
zfs destroy [-Rdnprv] filesystem|volume@snap[%snap[,snap[%snap]]]...
...
       An inclusive range of snapshots may be specified by separating the first and last snapshots with a percent sign.  The first and/or last snapshots may be left blank, in which case the filesystem's oldest or newest snapshot
       will be implied.
...
meaning you can use zfs destory dataset@%last_destroyed_snap to clear all older ones and the one specified.
 
  • Like
Reactions: Elleni
Perfect. Did not find that info in man myself, thats why I want to warmly thank you for providing me this very useful information.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!