On 9/30/2014 8:31 PM, Tim Aslat wrote:
Harry Putnam wrote on 01/10/2014 09:52:
This is not so easy to find in google searches

How does one go about destroying all but a specific snapshot?  The one
I want is somewhere in the middle timewise So not wanting to use
`destroy -r'.

This is in a .zfs/snapshot/* where there are many auto snaps. So
looking for a way besides destroying -r or 1 by 1.

Hi Harry,


Simplest option would be something like

zfs list -t snapshot -o name -H -r filesystem/path > /tmp/snaplist.txt

edit /tmp/snaplist.txt to remove the snapshot you want to keep

for SNAP in `cat /tmp/snaplist.txt`
do
        zfs destroy $SNAP
done



Here's an equivalent one liner for you.

zfs list -t snapshot -H <pool> | grep -v "the one you want to exclude" | awk '{print $1}' | xargs -n 1 zfs destroy

(you should run up to the last pipe and confirm that's what you want before adding on the xargs. ;)

* warning: if you have replication to a backup server, removing all of the snapshots for other filesystems will make those replicated snapshots non-operative.


_______________________________________________
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
http://openindiana.org/mailman/listinfo/openindiana-discuss

Reply via email to