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 "$mylockdir" >/dev/null 2>&1; then
date >> $logfile
# Special filesystems
-zfs-autosnap storage /storage $numsnapshots 15
-zfs-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
-zfs-autosnap tank / $numsnapshots $maxagedays
-zfs-autosnap tank/home /home $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
fi
elsif(($in_totals == 1) && ($line =~ /(\S+)\s+([\d\.]*)(\w+)\s+(\d+)/)) {
$filesystem = $1; $data = $2; $size = $3; $num_snaps = $4;
if($filesystem =~ /Snapshots/ || $filesystem =~ /Total/) { next; }
- if($filesystem =~ /$backup_pool/) { next; }
+ if($filesystem =~ /^$backup_pool/) { next; }
if(length($filesystem) > $maxlen) { $maxlen = length($filesystem); }
if($size =~ /K/i) { $data = $data * $kilo; }
if($size =~ /M/i) { $data = $data * $mega; }