fi
if [ -n "$SNAP_UNDER_TEST" ]; then
- snapshotdir="./snapshot"
+ snapshots=$(ls -d ./snapshot/????-??-??.??.?? 2>/dev/null)
else
- snapshotdir="${mountpoint}/.zfs/snapshot"
-fi
-
-if [ ! -d "$snapshotdir" ]; then
- echo "-E- Unable to find the snapshotdir: $snapshotdir"
- exit 1
+ snapshots=$(zfs list -H -t snapshot -o name $filesystem | grep -P "\d+-\d+\.\d+\.\d+")
fi
# Check to see if this zfs filesystem has a scrub being performed on it now.
trap cleanup EXIT
# Trim them down
-snapshots=$(ls -d ${snapshotdir}/????-??-??.??.?? 2>/dev/null)
for snapshot in $snapshots; do
snapminutes=$(echo "$snapshot" | sed 's,.*/,,' | datetime_to_minutes)
snapminutes2=$(echo "$snapshot" | sed 's,.*/,,' | datetime_to_minutes2)
if [ $age -lt $((window * numsnapshots)) ]; then
case $((snapminutes2 % window)) in
0) ;;
- *)
- snapname=${filesystem}$(echo "$snapshot" |
- sed 's,/\(.*\)/.zfs/snapshot/\(.*\),@\2,')
- destroy "$snapname"
- ;;
+ *) destroy "$snapshot" ;;
esac
break
fi
window=$((window*2))
done
if [ $maxagedays -gt 0 ] && [ $age -gt $((maxagedays * 24 * 60)) ]; then
- snapname=${filesystem}$(echo "$snapshot" |
- sed 's,/\(.*\)/.zfs/snapshot/\(.*\),@\2,')
- destroy "$snapname"
+ destroy "$snapshot"
fi
done