[OpenIndiana-discuss] destroy all but specific snapshot

Harry Putnam reader at newsguy.com
Wed Oct 1 01:53:14 UTC 2014


Tim Aslat <tim at spyderweb.com.au> writes:

> 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
>
> My syntax may be a little off with the for loop but I'm sure you get the
> idea.
>
> Cheers

Thanks for the input... I did think of something like that employing
a four loop but it seemed a bit cumbersome 

So I thought I'd check once more thru the oracle stuff online about
snapshots and damned if I didn't stumble up on something that seems to
be one way to go, honestly its not a whole lot less (if any) less
cumbersome though.

  http://docs.oracle.com/cd/E19253-01/819-5461/6n7ht6r4f/index.html
      (Look under Holding ZFS Snapshots)
 

It revolves around the `hold' command which is really more of a
property I guess.

You pick out the snap[s] you  want (in my case it was just one) and
label it with: `zfs hold LABEL zp/path/dir at SNAP'

Then you maybe use the -r flag with destroy or a four loop like I did:

I didn't have any complicated snaps behind clones or what not.

cd .../.zfs/snspshot  

  for SNAP in `ls -d *`;do zfs destroy zp/path/dir@${SNAP};done

When it hits the one with the `hold NAME' it reports that fact then
finishes off the rest.

You can then `release' the `hold' with: zfs release zp/path/dir at SNAP




More information about the openindiana-discuss mailing list