X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=zfs-autosnap-wrapper;h=fc17c0872bc3e0c2c83efde7da266c235ee3e437;hb=e0a76f5554c04eff63938bb1232f39130713c7ad;hp=813d9fe6140edbe2188df8bc057da490b37616af;hpb=e52d277a87f755e063e35a74fbc2a94de84a4462;p=zfs-ubuntu%2F.git diff --git a/zfs-autosnap-wrapper b/zfs-autosnap-wrapper index 813d9fe..fc17c08 100755 --- a/zfs-autosnap-wrapper +++ b/zfs-autosnap-wrapper @@ -4,16 +4,23 @@ # 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" -lockdir="/tmp/zfs-autosnap-all" +logfile="$logdir/zfs-autosnap.log" numsnapshots=20 maxagedays=365 date=`date` +mylockdir="/tmp/zfs-autosnap-all" +current_hour=`date +"%H"` +current_minute=`date +"%M"` +current_day=`date +"%u"` # Make sure we aren't already running -if ! mkdir "$lockdir" >/dev/null 2>&1; then +if ! mkdir "$mylockdir" >/dev/null 2>&1; then echo "$date Another $0 process is already running" >> $logfile exit 1 fi @@ -22,27 +29,23 @@ fi date >> $logfile # Special filesystems -$autosnap storage /storage $numsnapshots 15 -$autosnap tank/usr/videos /usr/videos $numsnapshots 15 +# ex: zfs-autosnap storage /storage $numsnapshots 15 +# ex: 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 +# ex: zfs-autosnap tank / $numsnapshots $maxagedays +# ex: zfs-autosnap tank/home /home $numsnapshots $maxagedays # Daily filesystems (only perform these at midnight) -if [ `date +"%H:%M"` == "00:00" ]; then +# midnight = true if (midnight < current time < midnight+5 min) +if [[ $current_hour == "00" && $current_minute -lt 5 ]]; then echo "Performing Daily snapshots" >> $logfile fi # Weekly filesystems (only perform these on Sunday at midnight) -if [ `date +"%H:%M:%u"` == "00:00:7" ]; then +# midnight = true if (midnight < current time < midnight+5 min) +if [[ $current_day == "7" && $current_hour == "00" && $current_minute -lt 5 ]]; then echo "Performing Weekly snapshots" >> $logfile - $autosnap tank/var /var $numsnapshots 60 - $autosnap tank/usr/local/var /usr/local/var $numsnapshots 60 fi -rm -rf "$lockdir" +rm -rf "$mylockdir"