Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

destroy-zfs-auto-snaps-for-fs.sh

gregthegeek Nov 24th, 2012 559 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #!/usr/bin/env bash
  2.  
  3. if [ -n "${1}" ]
  4. then
  5.         echo "This will *RECURSIVELY* destroy all ZFS auto snapshots (not your manually created snaps). "
  6.         echo "Parent and child filesystem snapshots to be destroyed: ${1}"
  7.         echo "Continue? (y/n)"
  8.         read ANS
  9.  
  10.         if [ $ANS == "y" ]
  11.         then
  12.                 echo "Listing snapshots to be destroyed..."
  13.                 for ii in $(zfs list -r -t snapshot -o name ${1} | grep @zfs-auto-snap); do echo $ii; done
  14.                 echo "The above snapshots will be destroyed, sound like a plan? (y/n)"
  15.                 read PLAN
  16.                 if [ $PLAN == "y" ]
  17.                 then
  18.                         for ii in $(zfs list -r -t snapshot -o name ${1} | grep @zfs-auto-snap); do echo $ii; zfs destroy $ii; done
  19.                         echo "ZFS Auto snaps for ${1} destroyed!"
  20.                 else
  21.                         echo "Not a plan then... exiting."
  22.                 fi
  23.                
  24.         else
  25.                 echo "Not destroying... exit."
  26.         fi
  27.        
  28.         echo "Done."
  29. else
  30.         echo "Exiting. You did not provide a ZFS filesystem.  (destroy-zfs-auto-snaps-for-fs.sh zpool/some/fs)"
  31. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top