Delete all Snapshots

Status
Not open for further replies.

Catsrules

Dabbler
Joined
Jan 7, 2015
Messages
33
I have gone a little overboard on my Snapshots (24000+) I was young and naive this being my first FreeNAS box and didn't know any better. Now I am seeing that managment and performance is starting to take a hit. I am trying to mend my ways and come back to a much more manageable snapshot system. I have fixed my Periodic Snapshot tasks so I am snapshot less and keeping them shorter amount of time.

Now to my question is there a fast way to remove every snapshot on the system and just start over?
 
D

dlavigne

Guest
There's no fast way as ZFS needs to determine if any existing snapshots depend upon the snapshots being deleted. If you have that many, it's gonna take a (long) while... Best to start the process when the system isn't under heavy use.
 
Joined
Nov 17, 2015
Messages
1
I was in the same boat as you actually, my snapshots had gotten all messed up due to some failed replications and long story short I ended up with way too many on disk. In my scenario, I stopped all automated snapshot tasks and removed all replication tasks as well, as I was intending on reseeding the replication from scratch anyway.

I used a script with a simple for loop to enumerate the snapshots and delete them, one by one. This greatly reduces the amount of work I had to do though as I didn't have to go through each one individually. Hope this helps.

Code:
#!/bin/bash
for snapshot in `zfs list -H -t snapshot | cut -f 1`
do
zfs destroy $snapshot
done
 

bollar

Patron
Joined
Oct 28, 2012
Messages
411
This was helpful. I'd change the second line as follows, so the system snapshots aren't deleted (replace tank with your pool name):

Code:
for snapshot in `zfs list -H -t snapshot -r tank | cut -f 1`
 
Status
Not open for further replies.
Top