X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=zfs-autosnap-wrapper;h=ab09272e22c471d1609ec251337dbdf1002fd1f5;hb=be0effa3f84fee2396403d3c9220ba24a50f7b35;hp=ad8f4fc371fec7c7e4ab7a993c6a812c161c822d;hpb=698062c29aad5253bc10d488958de289055429e5;p=zfs-ubuntu%2F.git diff --git a/zfs-autosnap-wrapper b/zfs-autosnap-wrapper index ad8f4fc..ab09272 100755 --- a/zfs-autosnap-wrapper +++ b/zfs-autosnap-wrapper @@ -4,30 +4,43 @@ # Description: This script is a wrapper script that calls zfs-autosnap # for each filesystem provided below. +# source our configuration +config="${0%/*}/zfs-scripts.conf" +[ -e "${config}.dist" ] && . ${config}.dist +[ -e "${config}" ] && . ${config} + # Setup some default values -autosnap="/usr/local/etc/bin/zfs-autosnap" -logfile="/var/log/zfs/zfs-autosnap.log" +logfile="$logdir/zfs-autosnap.log" numsnapshots=20 maxagedays=365 +date=`date` +mylockdir="/tmp/zfs-autosnap-all" + +# Make sure we aren't already running +if ! mkdir "$mylockdir" >/dev/null 2>&1; then + echo "$date Another $0 process is already running" >> $logfile + exit 1 +fi # Auto snapshot every zfs filesystem on the system specified below date >> $logfile # Special filesystems -$autosnap storage /storage $numsnapshots 15 -$autosnap tank/usr/videos /usr/videos $numsnapshots 15 +zfs-autosnap storage /storage $numsnapshots 15 +zfs-autosnap tank/usr/videos /usr/videos $numsnapshots 15 # Normal filesystems -$autosnap tank / $numsnapshots $maxagedays -$autosnap tank/backup /backup $numsnapshots $maxagedays -$autosnap tank/usr /usr $numsnapshots $maxagedays -$autosnap tank/usr/home /usr/home $numsnapshots $maxagedays -$autosnap tank/usr/local /usr/local $numsnapshots $maxagedays -$autosnap tank/usr/local/etc /usr/local/etc $numsnapshots $maxagedays +zfs-autosnap tank / $numsnapshots $maxagedays +zfs-autosnap tank/home /home $numsnapshots $maxagedays # Daily filesystems (only perform these at midnight) if [ `date +"%H:%M"` == "00:00" ]; then - $autosnap tank/var /var $numsnapshots $maxagedays - $autosnap tank/usr/local/var /usr/local/var $numsnapshots $maxagedays + echo "Performing Daily snapshots" >> $logfile +fi + +# Weekly filesystems (only perform these on Sunday at midnight) +if [ `date +"%H:%M:%u"` == "00:00:7" ]; then + echo "Performing Weekly snapshots" >> $logfile fi +rm -rf "$mylockdir"