# 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}
-if [ -z "$SNAP_UNDER_TEST" ]; then
- exec >> /var/log/zfs/zfs-autosnap.log 2>&1
+if [[ -z "$SNAP_UNDER_TEST" ]]; then
+ exec >> $logdir/zfs-autosnap.log 2>&1
fi
# This script makes the following assumptions/requirements:
mountpoint=${2-/$1}
numsnapshots=${3-12}
maxagedays=${4-0}
-lockdir="/tmp/${filesystem}.lock"
pool=`echo "$filesystem" | awk -F '/' '{ print $1 }'`
if [ -z "$filesystem" ] || [ -z "$mountpoint" ] || [ -z "$numsnapshots" ] || [ -z "$maxagedays" ]; then
minutes=$(echo $datetime | datetime_to_minutes)
-lockdir="/tmp/zfs-admin-lock"
if ! mkdir "$lockdir" >/dev/null 2>&1; then
+ echo "-W- The zfs filesystem has been locked down. Skipping snapshot cleanup."
exit 0
fi
cleanup() { rm -rf "$lockdir"; }