# It also employs an intelligent algorithm to roll off,
# or destroy, old snapshots.
# It also employs an intelligent algorithm to roll off,
# or destroy, old snapshots.
-PATH=/usr/sbin:/sbin:$PATH
+# source our configuration
+config="${0%/*}/zfs-scripts.conf"
+[ -e "${config}.dist" ] && . ${config}.dist
+[ -e "${config}" ] && . ${config}
pool=`echo "$filesystem" | awk -F '/' '{ print $1 }'`
if [ -z "$filesystem" ] || [ -z "$mountpoint" ] || [ -z "$numsnapshots" ] || [ -z "$maxagedays" ]; then
pool=`echo "$filesystem" | awk -F '/' '{ print $1 }'`
if [ -z "$filesystem" ] || [ -z "$mountpoint" ] || [ -z "$numsnapshots" ] || [ -z "$maxagedays" ]; then
- 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.
# If it does, we cannot perform any snapshot create or destroy operations.
if [ -z "$SNAP_UNDER_TEST" ]; then
fi
# Check to see if this zfs filesystem has a scrub being performed on it now.
# If it does, we cannot perform any snapshot create or destroy operations.
if [ -z "$SNAP_UNDER_TEST" ]; then
for snapshot in $snapshots; do
snapminutes=$(echo "$snapshot" | sed 's,.*/,,' | datetime_to_minutes)
snapminutes2=$(echo "$snapshot" | sed 's,.*/,,' | datetime_to_minutes2)
for snapshot in $snapshots; do
snapminutes=$(echo "$snapshot" | sed 's,.*/,,' | datetime_to_minutes)
snapminutes2=$(echo "$snapshot" | sed 's,.*/,,' | datetime_to_minutes2)
- *)
- snapname=${filesystem}$(echo "$snapshot" |
- sed 's,/\(.*\)/.zfs/snapshot/\(.*\),@\2,')
- destroy "$snapname"
- ;;
+ *) destroy "$snapshot" ;;