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
This commit is contained in:
Micah Anderson 2012-11-26 12:27:40 -05:00
parent 1790b5332b
commit 090cef2438

View File

@ -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'
if [ -n "$srcconffile" ]; then
srcconffile="-c $srcconffile"
fi
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 <<EOF
##### BEGIN REMOTE SCRIPT #####
@ -184,11 +178,6 @@ function do_rotate() {
continue 1
fi
if [ -f \$target ]; then
echo "Warning: \$target exists. Previous backup did not complete properly. Skipping rotation."
continue 1
fi
# Rotate the current list of backups, if we can.
oldest=\`find $backuproot -maxdepth 1 -type d -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
#echo "Debug: oldest \$oldest"
@ -276,7 +265,7 @@ function setup_remote_dirs() {
if [ -d $tmpdir ]; then
mv $tmpdir $dir.1
if [ \$? == 1 ]; then
echo "Fatal: could mv $stripped_destdir/rotate.tmp $dir.1 on host $desthost"
echo "Fatal: could not mv $stripped_destdir/rotate.tmp $dir.1 on host $desthost"
exit 1
fi
else