[PC-BSD Commits] r4939 - in pcbsd/trunk/lifePreserver: . scripts

svn at pcbsd.org svn at pcbsd.org
Tue Nov 10 13:54:07 PST 2009


Author: kris
Date: 2009-11-10 13:54:07 -0800 (Tue, 10 Nov 2009)
New Revision: 4939

Modified:
   pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
   pcbsd/trunk/lifePreserver/lifePreserverSettings.ui
   pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp
   pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh
   pcbsd/trunk/lifePreserver/scripts/functions.sh
Log:

Updated life-presserver further, now it works with the settings we offer, such as only keeping a certian
number of backups on the remote, and removing any failed backups



Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-10 21:44:13 UTC (rev 4938)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-10 21:54:07 UTC (rev 4939)
@@ -1,7 +1,6 @@
 /***************************************************************************
- *   Copyright (C) 2006 - 2008 PC-BSD Software   *
+ *   Copyright (C) 2006 - 2009 PC-BSD Software   *
  *   kris at pcbsd.com  *
- *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
  *   a copy of this software and associated documentation files (the       *

Modified: pcbsd/trunk/lifePreserver/lifePreserverSettings.ui
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverSettings.ui	2009-11-10 21:44:13 UTC (rev 4938)
+++ pcbsd/trunk/lifePreserver/lifePreserverSettings.ui	2009-11-10 21:54:07 UTC (rev 4939)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>pSettings</class>
- <widget class="QDialog" name="pSettings">
+ <widget class="QWidget" name="pSettings">
   <property name="geometry">
    <rect>
     <x>0</x>
@@ -27,7 +27,11 @@
       <item row="0" column="0">
        <layout class="QHBoxLayout" name="horizontalLayout_2">
         <item>
-         <widget class="QSpinBox" name="spinNumBackups"/>
+         <widget class="QSpinBox" name="spinNumBackups">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+         </widget>
         </item>
         <item>
          <widget class="QLabel" name="label">

Modified: pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp	2009-11-10 21:44:13 UTC (rev 4938)
+++ pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp	2009-11-10 21:54:07 UTC (rev 4939)
@@ -1,7 +1,6 @@
 /***************************************************************************
- *   Copyright (C) 2006 - 2008 PC-BSD Software   *
+ *   Copyright (C) 2006 - 2009 PC-BSD Software   *
  *   kris at pcbsd.com  *
- *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
  *   a copy of this software and associated documentation files (the       *

Modified: pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh	2009-11-10 21:44:13 UTC (rev 4938)
+++ pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh	2009-11-10 21:54:07 UTC (rev 4939)
@@ -13,7 +13,7 @@
 PROGDIR="/PCBSD/lifePreserver"
 HOSTDIR="${PROGDIR}/preservers/${SSHHOST}"
 BACKDIR="life-preserver"
-BACKLOG="${HOSTDIR}/logs/${SSHHOST}${DATE}.log"
+BACKLOG="${HOSTDIR}/logs/${DATE}.log"
 EXCLUDELIST="/PCBSD/lifePreserver/conf/rsync-excludes"
 PIDFILE="${HOSTDIR}/preserver.pid"
 RESULTFILE="${HOSTDIR}/last-result"
@@ -53,7 +53,7 @@
 
 # Save the PID of this running process
 check_pid ${PIDFILE}
-if "$?" = "1" ]
+if [ "$?" = "1" ]
 then
   echo "Failed: ${STARTDATE}" >${RESULTFILE}
   echo "Failed: Backup already running? PID: $PID" >${BACKLOG}
@@ -80,21 +80,57 @@
   && rm -f ${BACKDIR}/current \
   && ln -s back-${DATE} ${BACKDIR}/current"
 
-if [ "$?" = "0" ]
+RESULT="$?"
+
+if [ "$RESULT" = "0" ]
 then
-  bzip2 ${BACKLOG}
   # Success!
-  # Copy the logfile to the backup dir
-  sftp -oPORT=${PORT} ${SSHHOST} << EOF
-cd ${BACKDIR}/current
-put ${BACKLOG}.bz2 backup.log.bz2
-quit
-EOF
   echo "Success: ${STARTDATE}" >${RESULTFILE}
 else
   # Failed backup!
   echo "Failed: ${STARTDATE}" >${RESULTFILE}
 fi
 
+# Check if we need to cleanup any failed backups
+if [ "$CLEANFAILED" = "true" ]
+then
+  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} 
+fi
+
+# Check if we need to prune any old saved backups
+if [ ! -z "${KEEPNUM}" ]
+then
+  COUNT="0"
+
+  # Get a listing of the number of full backups saved
+  OLDBACKUPS=`ssh -p ${PORT} ${SSHHOST} "cd ${BACKDIR}/ && ls -dt back-*"`
+  if [ "$?" = "0" ]
+  then
+    for i in ${OLDBACKUPS}
+    do
+      COUNT="`expr $COUNT + 1`"
+      if [ $COUNT -gt $KEEPNUM -a ! -z "${i}" ]
+      then
+        # 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}
+      fi
+    done 
+  fi
+fi
+
+# Compress our logfile to save disk space
+bzip2 ${BACKLOG}
+
 # Remove the PID
 rm ${PIDFILE}

Modified: pcbsd/trunk/lifePreserver/scripts/functions.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/functions.sh	2009-11-10 21:44:13 UTC (rev 4938)
+++ pcbsd/trunk/lifePreserver/scripts/functions.sh	2009-11-10 21:54:07 UTC (rev 4939)
@@ -27,5 +27,5 @@
     fi
   fi
 
-  return VAL
+  export VAL
 };



More information about the Commits mailing list