This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
fsWithSnapshots=$(zfs list -Hr -t snapshot tank/share |grep '@' |cut -d '@' -f 1 |uniq) | |
for fs in $fsWithSnapshots ; do | |
# Changed to now sort newest to oldest. This will mean that newer snapshots without deltas will get removed. | |
emptySnapshot=$(zfs list -Hr -d1 -t snapshot -o name,used -S creation $fs |sed '$d' |awk ' $2 == "0B" { print $1 }' ) | |
for snapshot in $emptySnapshot ; do | |
# Added safety check. Verify the size of the snapshot prior to destroying it |