[PC-BSD Commits] r6296 - pcbsd/trunk/lifePreserver/scripts

svn at pcbsd.org svn at pcbsd.org
Wed Feb 24 09:57:10 PST 2010


Author: kris
Date: 2010-02-24 09:57:10 -0800 (Wed, 24 Feb 2010)
New Revision: 6296

Modified:
   pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh
   pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh
Log:

Updated more life-preserver backup script, fixes more issues when no remote shell available
on the other side



Modified: pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh	2010-02-24 17:28:53 UTC (rev 6295)
+++ pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh	2010-02-24 17:57:10 UTC (rev 6296)
@@ -74,12 +74,7 @@
   --exclude-from ${EXCLUDELIST} \
   -e "ssh -p ${PORT}" \
   --link-dest=../current \
-  / ${SSHHOST}:${BACKDIR}/incomplete_back-$DATE \
-  && ssh -p ${PORT} ${SSHHOST} \
-  "mv ${BACKDIR}/incomplete_back-$DATE ${BACKDIR}/back-$DATE \
-  && touch ${BACKDIR}/back-$DATE \
-  && rm -f ${BACKDIR}/current \
-  && ln -s back-${DATE} ${BACKDIR}/current"
+  / ${SSHHOST}:${BACKDIR}/incomplete_back-$DATE
 
 RESULT="$?"
 
@@ -87,6 +82,13 @@
 then
   # Success!
   echo "Success: ${STARTDATE}" >${RESULTFILE}
+
+  ssh -p ${PORT} ${SSHHOST} \
+  "mv ${BACKDIR}/incomplete_back-$DATE ${BACKDIR}/back-$DATE \
+  ; touch ${BACKDIR}/back-$DATE \
+  ; rm -f ${BACKDIR}/current \
+  ; ln -s back-${DATE} ${BACKDIR}/current"
+
 else
   # Failed backup!
   echo "Failed: ${STARTDATE}" >${RESULTFILE}
@@ -98,10 +100,8 @@
   echo "Cleaning up incomplete backups..."
   echo "Cleaning up incomplete backups..." >>${BACKLOG}
   ssh -p ${PORT} ${SSHHOST} \
-  "cd ${BACKDIR}/ \
-  && chflags -R noschg incomplete_back-* \
-  && chmod -R 777 incomplete_back-* \
-  && rm -rf incomplete_back-*" >>${BACKLOG} 2>>${BACKLOG} 
+  "chmod -R 777 ${BACKDIR}/incomplete_back-* \
+; rm -rf ${BACKDIR}/incomplete_back-*" >>${BACKLOG} 2>>${BACKLOG} 
 fi
 
 # Check if we need to prune any old saved backups
@@ -110,7 +110,7 @@
   COUNT="0"
 
   # Get a listing of the number of full backups saved
-  OLDBACKUPS=`ssh -p ${PORT} ${SSHHOST} "cd ${BACKDIR}/ && ls -dt back-*"`
+  OLDBACKUPS=`ssh -p ${PORT} ${SSHHOST} "ls -dt ${BACKDIR}/back-*"`
   if [ "$?" = "0" ]
   then
     for i in ${OLDBACKUPS}
@@ -121,10 +121,9 @@
         # We've found a backup to delete, do it now
         echo "Removing old backup: ${i}"
         echo "Removing old backup: ${i}" >>${BACKLOG}
-        ssh -p ${PORT} ${SSHHOST} "cd ${BACKDIR} \
-        && chflags -R noschg ${i} \
-        && chmod -R 777 ${i} \
-        && rm -rf ${i}" >>${BACKLOG} 2>>${BACKLOG}
+        ssh -p ${PORT} ${SSHHOST} "chflags -R noschg ${i} \
+        ; chmod -R 777 ${i} \
+        ; rm -rf ${i}" >>${BACKLOG} 2>>${BACKLOG}
       fi
     done 
   fi

Modified: pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh	2010-02-24 17:28:53 UTC (rev 6295)
+++ pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh	2010-02-24 17:57:10 UTC (rev 6296)
@@ -36,16 +36,17 @@
 fi
 
 # Get a listing of the number of full backups saved
-OLDBACKUPS=`ssh -p ${PORT} ${SSHHOST} "cd ${BACKDIR}/ ; ls -dt back-*"`
+OLDBACKUPS=`ssh -p ${PORT} ${SSHHOST} "ls -dt ${BACKDIR}/back-*"`
 if [ "$?" = "0" ]
 then
   for i in ${OLDBACKUPS}
   do
+    DIR=`echo ${i} | sed "s|^${BACKDIR}/||g"`
     if [ -z "${BACKLIST}" ]
     then
-      BACKLIST="${i}"
+      BACKLIST="${DIR}"
     else
-      BACKLIST="${BACKLIST}:${i}"
+      BACKLIST="${BACKLIST}:${DIR}"
     fi
   done
 



More information about the Commits mailing list