# Setup some default values
zfsreplicate="/etc/bin/zfs-replicate"
+logdir="/var/log/zfs"
logfile_parser="/etc/bin/zfs-log-parser"
-logfile="/var/log/zfs/zfs-replicate.log"
+logfile="$logdir/zfs-replicate.log"
+mylogfile="$logdir/zfs-replicate-all.log"
remote="tank.pippins.net"
local_pool=backups
mailto=root@pippins.net
naspool/git
'
-# Specify the maximum run time in minutes that this script can run
+# Specify the maximum run time in minutes that this script can run (0=no limit)
maxruntime=240
# This function checks to see if our runtime has exceeded our stoptime
timeexceeded() {
+ if [[ $maxruntime == 0 ]]; then
+ return 0
+ fi
currenttime=`date +%s`
elapsedtime=$(($currenttime - $starttime))
stoptime=$(($maxruntime*60))
# Auto snapshot every zfs filesystem on the system specified below
echo "$date ZFS replicate started" >> $logfile
+echo "$date ZFS replicate started" | tee -a $mylogfile
# Sort the filesystems to replicate by the oldest backup first
tmpfile=`tempfile`
# Replicate the sorted filesystems
for filesystem in $sorted_filesystems; do
- echo "-> Replicating $remote:$filesystem to ${local_pool}/${filesystem}"
+ echo "-> Replicating $remote:$filesystem to ${local_pool}/${filesystem}" | tee -a $mylogfile
replicate $remote $filesystem
done
# All done
echo `date` ZFS replicate complete >> $logfile
+echo `data` ZFS replicate complete | tee -a $mylogfile
# Parse the log file and extract our backup stats
$logfile_parser "$logfile" "$date" >> $logfile
+$logfile_parser "$logfile" "$date" | tee -a $mylogfile