#!/bin/bash # Author: Alan J. Pippin # 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 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 zfs-autosnap storage /storage $numsnapshots 15 zfs-autosnap tank/usr/videos /usr/videos $numsnapshots 15 # Normal filesystems 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 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"