Select all of ZFS snapshots for deletion in one click

Status
Not open for further replies.

M H

Explorer
Joined
Sep 16, 2013
Messages
98
UPD: I've risked it ;-).. To help others searching for cleanup space from a lot of snapshots:

1. Get the space used by snapshots vs real data:
Code:
zfs list -o space -t all pool1/shares


Notice: the real space used by a snapshot is not visible without the "-o space".

2. List all the snapshots for a folder:
Code:
zfs list -t snapshot | grep /XXX | less


Notice: I was not able to list it like "zfs list -t snapshot pool1/", as I wanted to refer to the "root" of pool1, which FreeNAS describes like "pool1/pool1", which is a bit confusing (named "volume", but it's an root dataset filesystem). I didn't know what to enter after the "pool1/" as "pool1/pool1" didn't work. So greped for it - somebody could give me a clue probably :).

3. Look what would (e.g. simulate by "-n") happen cleaning those up:
Code:
zfs destroy -rvn POOL/XXX@%


Notice: % stands for wildcard. This shows also how much space would be freed up.

4. Empty 'em
..just leave out "-n" from the command above

The response is immediate, no waiting or anything like that: I looked for zfs doing something async, nope, nothing, "htop" gave nothing, "ps -ax | grep zfs" nothing - I thought I made a mistake, but this is really so fast!

And FreeNAS GUI is happy, space is freed up!

Happy Sunday :)

Sorry to resurrect this old thread, but I just had to say thanks for this VERY useful post (combined with fracai's). I had some iSCSI targets within my snapshot'd dataset that quickly filled my array. I'm still on 9.10, so the GUI is really flakey when it comes to cleaning up snapshots. This solved my problem instantly! Thanks!
 

brumnas

Dabbler
Joined
Oct 4, 2015
Messages
33
..glad it helped you ;-)! Have a nice day (here in Switzerland: very hot days currently!)
 
Status
Not open for further replies.
Top