projects
/
zfs-nexenta
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added configuration scripts to hold customized options
[zfs-nexenta/.git]
/
zfs-replicate-wrapper
diff --git
a/zfs-replicate-wrapper
b/zfs-replicate-wrapper
index d699c792e424197ecfb61ab9ac1952282b5915b0..c6c3369e5eec98211424805191b6091bc18f2a42 100755
(executable)
--- a/
zfs-replicate-wrapper
+++ b/
zfs-replicate-wrapper
@@
-4,28
+4,22
@@
# Description: This script calls zfs-replicate for each filesystem needing
# to be backed up, or replicated, to another ZFS pool.
# Description: This script calls zfs-replicate for each filesystem needing
# to be backed up, or replicated, to another ZFS pool.
+# source our configuration
+config="${0%/*}/zfs-scripts.conf"
+[ -e "${config}.dist" ] && . ${config}.dist
+[ -e "${config}" ] && . ${config}
+
# Setup some default values
# Setup some default values
-zfsreplicate="/etc/bin/zfs-replicate"
-logfile_parser="/etc/bin/zfs-log-parser"
-logfile="/var/log/zfs/zfs-replicate.log"
-remote="tank.pippins.net"
-local_pool=backups
-mailto=root@pippins.net
+logfile="$logdir/zfs-replicate.log"
+mylogfile="$logdir/zfs-replicate-all.log"
date=`date`
starttime=`date +%s`
date=`date`
starttime=`date +%s`
-zfs=/usr/sbin/zfs
-
-# Specify the list of filesystems to replicate
-filesystems_to_replicate='
-naspool/www
-naspool/git
-'
-
-# Specify the maximum run time in minutes that this script can run
-maxruntime=240
# This function checks to see if our runtime has exceeded our stoptime
timeexceeded() {
# 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))
currenttime=`date +%s`
elapsedtime=$(($currenttime - $starttime))
stoptime=$(($maxruntime*60))
@@
-47,7
+41,7
@@
trap cleanup_and_exit INT
# This function executes the replicate command and checks the stoptime
replicate() {
# This function executes the replicate command and checks the stoptime
replicate() {
-
$zfs
replicate $* >> $logfile 2>&1
+
zfs-
replicate $* >> $logfile 2>&1
timeexceeded
if [ $? == 1 ]; then
cleanup_and_exit
timeexceeded
if [ $? == 1 ]; then
cleanup_and_exit
@@
-86,6
+80,7
@@
previous_backup_marker=@previous-backup-${local_pool_guid}
# Auto snapshot every zfs filesystem on the system specified below
echo "$date ZFS replicate started" >> $logfile
# 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`
# Sort the filesystems to replicate by the oldest backup first
tmpfile=`tempfile`
@@
-98,13
+93,15
@@
rm -f $tmpfile
# Replicate the sorted filesystems
for filesystem in $sorted_filesystems; do
# 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
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
# Parse the log file and extract our backup stats
-$logfile_parser "$logfile" "$date" >> $logfile
+zfs-log-parser "$logfile" "$date" >> $logfile
+zfs-log-parser "$logfile" "$date" | tee -a $mylogfile