From 090cef24382fc43200ebbd1a22283f2453a88ae8 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Mon, 26 Nov 2012 12:27:40 -0500 Subject: fix quoting on srcconffile and destcconffile stop attempting to sync to current_backup, because if we do this then we do this then we don't take advantage of the hardlinking that is done later --- handlers/dsync.in | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/handlers/dsync.in b/handlers/dsync.in index bf7b51d..cae4aac 100644 --- a/handlers/dsync.in +++ b/handlers/dsync.in @@ -72,19 +72,12 @@ stripped_srcdir=${srcdir/*:/} destdir=${destdir%/} srcdir=${srcdir%/} -if [ ! -n $destdir ]; then - destdir='-o mail_location=$destdir' -fi -if [ ! -n $srcdir ]; then - srcdir='-o mail_location=$srcdir' -fi - -if [ ! -n $srcconffile ]; then - srcconffile='-c $srcconffile' +if [ -n "$srcconffile" ]; then + srcconffile="-c $srcconffile" fi -if [ ! -n $destconffile ]; then - destconffile='-c $destconffile' +if [ -n "$destconffile" ]; then + destconffile="-c $destconffile" fi [ -d $stripped_srcdir ] || fatal "source directory $srcdir doesn't exist" @@ -97,16 +90,20 @@ function do_user() { local user=$1 local btype=$2 local letter=${user:0:1} - local target="$stripped_destdir/$letter/$user/$current_backup" + local target="$stripped_destdir/$letter/$user/$btype.1" + local failedcount=0 + local ret=0 debug "syncing" while [ $failedcount -lt 4 ]; do - debug $DSYNC $testflags -u $user backup $srcconffile $srcdir \ + echo "failedcount: $failedcount" + echo "returned: $ret" + debug $DSYNC $testflags -u $user backup $srcconffile \ ssh -i $destid_file $destuser@$desthost $DSYNC $destconffile \ - -u $user $destdir 2>&1 - ret=`$DSYNC $testflags -u $user backup $srcconffile $srcdir \ + -u $user 2>&1 + ret=`$DSYNC $testflags -u $user backup $srcconffile \ ssh -i $destid_file $destuser@$desthost $DSYNC $destconffile \ - -u $user $destdir 2>&1` + -u $user 2>&1` ret=$? if [ $ret == 2 ]; then # dsync needs to be run again @@ -114,9 +111,7 @@ function do_user() { elif [ $ret == 0 ]; then # things worked, so we break out of the loop let "failedcount = 4" - # move the directory to the $btype.1 and make a 'created' file - ssh -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file $sshoptions "mv $target ../$btype.1" - ssh -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file $sshoptions "date +%c%n%s > ../$btype.1/created" + ssh -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file $sshoptions "date +%c%n%s > $stripped_destdir/$letter/$user/$btype.1/created" elif [ $ret != 0 ]; then # things did not work in a good way, report it and try again warning "dsync $user failed" @@ -159,7 +154,6 @@ function do_rotate() { local user=$1 local letter=${user:0:1} local backuproot="$stripped_destdir/$letter/$user" - local target="$stripped_destdir/$letter/$user/$current_backup" ( ssh -T -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file $sshoptions <