X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=zfs-autosnap;h=09e1a629b21ece6dbdd7a2f46c18aff4464b734a;hb=117f1e7cd08226590ffdc40c40464a2a8304ee7c;hp=cfe80aaab8adb067e0cfa1615186f716ce96f548;hpb=753ccca8d8d22675da30abf49bdda584aa5878ba;p=zfs-ubuntu%2F.git diff --git a/zfs-autosnap b/zfs-autosnap index cfe80aa..09e1a62 100755 --- a/zfs-autosnap +++ b/zfs-autosnap @@ -5,10 +5,13 @@ # 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: @@ -50,7 +53,6 @@ filesystem=$1 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 @@ -77,7 +79,7 @@ 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 - zpool status $pool | grep scrub: | grep "in progress" > /dev/null 2>&1 + zpool status $pool | grep scan: | grep "in progress" > /dev/null 2>&1 if [ $? == 0 ]; then echo "-W- The zfs pool '$pool' is currently being scrubbed. Skipping all snapshot operations." exit 0 @@ -111,8 +113,8 @@ snapshot "${filesystem}@${datetime}" 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"; }