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

svn at pcbsd.org svn at pcbsd.org
Wed Nov 11 11:41:43 PST 2009


Author: kris
Date: 2009-11-11 11:41:43 -0800 (Wed, 11 Nov 2009)
New Revision: 4950

Added:
   pcbsd/trunk/lifePreserver/lifePreserverListBackups.cpp
   pcbsd/trunk/lifePreserver/lifePreserverListBackups.h
   pcbsd/trunk/lifePreserver/lifePreserverListBackups.ui
   pcbsd/trunk/lifePreserver/lifePreserverRestore.cpp
   pcbsd/trunk/lifePreserver/lifePreserverRestore.h
   pcbsd/trunk/lifePreserver/lifePreserverRestore.ui
   pcbsd/trunk/lifePreserver/lifePreserverRestoreProgress.cpp
   pcbsd/trunk/lifePreserver/lifePreserverRestoreProgress.h
   pcbsd/trunk/lifePreserver/lifePreserverRestoreProgress.ui
Modified:
   pcbsd/trunk/lifePreserver/lPreserve.pro
   pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
   pcbsd/trunk/lifePreserver/lifePreserverMain.h
   pcbsd/trunk/lifePreserver/lifePreserverMain.ui
   pcbsd/trunk/lifePreserver/preserver.cpp
   pcbsd/trunk/lifePreserver/preserver.h
   pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh
Log:

HUGE update to lifePreserver, now we are able to do restores of specific files from the remote
rsync archive. Supports relative restores, allows listing of available backups, so you can pick
which one to restore from



Modified: pcbsd/trunk/lifePreserver/lPreserve.pro
===================================================================
--- pcbsd/trunk/lifePreserver/lPreserve.pro	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/lPreserve.pro	2009-11-11 19:41:43 UTC (rev 4950)
@@ -5,13 +5,31 @@
 
 LIBS += -L/usr/local/kde4/lib -lkdecore -lkio -lkdeui -Ikdelibs
 
-HEADERS	+= lifePreserverMain.h lifePreserverWizard.h lifePreserverSettings.h preserver.h
+HEADERS	+= lifePreserverMain.h \
+	lifePreserverWizard.h \
+	lifePreserverSettings.h \
+	lifePreserverRestore.h \
+	lifePreserverRestoreProgress.h \
+	lifePreserverListbackups.h \
+	preserver.h
 
-SOURCES	+= main.cpp lifePreserverMain.cpp lifePreserverWizard.cpp lifePreserverSettings.cpp preserver.cpp
+SOURCES	+= main.cpp \
+	lifePreserverMain.cpp \
+	lifePreserverWizard.cpp \
+	lifePreserverSettings.cpp \
+	lifePreserverRestore.cpp \
+	lifePreserverRestoreProgress.cpp \
+	lifePreserverListBackups.cpp \
+	preserver.cpp
 
 RESOURCES += lPreserve.qrc
 
-FORMS	= lifePreserverMain.ui lifePreserverWizard.ui lifePreserverSettings.ui
+FORMS	= lifePreserverMain.ui \
+	lifePreserverWizard.ui \
+	lifePreserverSettings.ui \
+	lifePreserverRestore.ui \
+	lifePreserverRestoreProgress.ui \
+	lifePreserverListBackups.ui
 
 #DESTDIR = /usr/local/kde4/bin
 
@@ -22,7 +40,13 @@
 TARGET=/usr/PCBSD/lifePreserver/bin/life-preserver
 
 scripts.path=/usr/PCBSD/lifePreserver/scripts
-scripts.files=scripts/setup-ssh-keys.sh scripts/start-backup.sh scripts/functions.sh scripts/backup-rsync.sh scripts/kill-backup.sh
+scripts.files=scripts/setup-ssh-keys.sh \
+	scripts/start-backup.sh \
+	scripts/functions.sh \
+	scripts/backup-rsync.sh \
+	scripts/restore-rsync.sh \
+	scripts/list-backup-rsync.sh \
+	scripts/kill-backup.sh
 
 conf.path=/usr/PCBSD/lifePreserver/conf
 conf.files=conf/rsync-excludes

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-11 19:41:43 UTC (rev 4950)
@@ -41,6 +41,8 @@
 #include "lifePreserverWizard.h"
 #include "ui_lifePreserverSettings.h"
 #include "lifePreserverSettings.h"
+#include "ui_lifePreserverListBackups.h"
+#include "lifePreserverListBackups.h"
 #include "preserver.h"
 #include "externals.h"
 
@@ -64,11 +66,27 @@
    connect(action_New_Preserver, SIGNAL( triggered(bool) ), this, SLOT(slotPushNewPreserverClicked() ) );
    connect(action_Edit, SIGNAL( triggered(bool) ), this, SLOT(slotPushEditPreserverClicked() ) );
    connect(action_Remove, SIGNAL( triggered(bool) ), this, SLOT(slotPushRemovePreserverClicked() ) );
+   connect(actionRestore, SIGNAL( triggered(bool) ), this, SLOT(slotPushRestorePreserverClicked() ) );
 
    // Start monitoring for changes
    QTimer::singleShot(5000, this, SLOT(slotScanPreserversForChanges() ) );
 }
 
+// Slot which brings up the restore widgets for a preserver
+void lifePreserver::slotPushRestorePreserverClicked()
+{
+  if (treePreservers->currentColumn() == -1)
+  {
+    return;
+  }
+
+  QString host = treePreservers->currentItem()->text(0);
+
+  lifeListBackups *lplb = new lifeListBackups();
+  lplb->widgetInit(host);
+  lplb->show();
+}
+
 // Slot which brings up a context menu for the preserver
 void lifePreserver::slotContextMenuPreserver()
 {
@@ -79,6 +97,7 @@
 
   QMenu *popup = new QMenu();
   popup->addAction( tr("Edit"), this, SLOT(slotPushEditPreserverClicked()));
+  popup->addAction( tr("Restore From"), this, SLOT(slotPushRestorePreserverClicked()));
   popup->addSeparator();
   popup->addAction( tr("Remove"), this, SLOT(slotPushRemovePreserverClicked()));
   popup->exec( QCursor::pos() );

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.h
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.h	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.h	2009-11-11 19:41:43 UTC (rev 4950)
@@ -12,6 +12,8 @@
 #include "lifePreserverWizard.h"
 #include "ui_lifePreserverSettings.h"
 #include "lifePreserverSettings.h"
+#include "ui_lifePreserverListBackups.h"
+#include "lifePreserverListBackups.h"
 
 /* KDE */
 #include <kmenu.h>
@@ -37,6 +39,7 @@
    void slotPushRemovePreserverClicked();
    void slotPushEditPreserverClicked();
    void slotPushPreserverStartClicked();
+   void slotPushRestorePreserverClicked();
    void slotCurrentTreePreserverChanged(QTreeWidgetItem *curItem);
    void loadPreservers();
    void slotScanPreserversForChanges();
@@ -44,6 +47,7 @@
 
 private:
    lifePreserverWizard *lpw;
+   lifeListBackups *lplb;
    pSettings *lps;
    QString getPreserverLastBackup(QString host);
    QString getPreserverFrequency(QString host);

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.ui
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.ui	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.ui	2009-11-11 19:41:43 UTC (rev 4950)
@@ -129,6 +129,7 @@
      <string>&amp;Preservers</string>
     </property>
     <addaction name="action_Edit"/>
+    <addaction name="actionRestore"/>
     <addaction name="separator"/>
     <addaction name="action_Remove"/>
    </widget>
@@ -155,6 +156,11 @@
     <string>&amp;Remove</string>
    </property>
   </action>
+  <action name="actionRestore">
+   <property name="text">
+    <string>Restore From</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="lPreserve.qrc"/>

Modified: pcbsd/trunk/lifePreserver/preserver.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/preserver.cpp	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/preserver.cpp	2009-11-11 19:41:43 UTC (rev 4950)
@@ -176,6 +176,11 @@
   setConfValue("port", port);
 }
 
+QString PRESERVER::getPreserverString()
+{
+  return connectHost;
+}
+
 QString PRESERVER::getHost()
 {
   return getConfValue("host").toString();
@@ -369,6 +374,28 @@
   return value;
 }
 
+// Function which returns a list of available backups to restore from
+QString PRESERVER::listServerBackups()
+{
+  QString command;
+  command = LIFEPRESERVERPATH + "/scripts/list-backup-rsync.sh " + connectHost;
+  
+  FILE *file = popen(command.toLatin1(),"r");
+
+  char buffer[10000];
+
+  QString line = "";
+  char firstChar;
+
+  if ((firstChar = fgetc(file)) != -1){
+     line += firstChar;
+     line += fgets(buffer,10000,file);
+  }
+  pclose(file);
+
+  return line;
+}
+
 void PRESERVER::setConfValue(QString key, QVariant value)
 {
    bool found;

Modified: pcbsd/trunk/lifePreserver/preserver.h
===================================================================
--- pcbsd/trunk/lifePreserver/preserver.h	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/preserver.h	2009-11-11 19:41:43 UTC (rev 4950)
@@ -45,6 +45,7 @@
     virtual QString getCronSettings();
     virtual int getPID();
     virtual bool getFailedCleanup();
+    virtual QString getPreserverString();
     
     //Setters
     virtual void setHost(QString userhost);
@@ -55,10 +56,12 @@
     virtual void setCron(QString hour, QString day);
     virtual void setFailedCleanup(bool enabled);
 
+    // Other Functions which take actions
     virtual void remove();
     virtual void removeCron();
     virtual void startBackup();
     virtual void stopBackup();
+    virtual QString listServerBackups();
 
 private:
     void setConfValue(QString key, QVariant value);

Modified: pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh	2009-11-11 18:54:35 UTC (rev 4949)
+++ pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh	2009-11-11 19:41:43 UTC (rev 4950)
@@ -48,7 +48,7 @@
 echo "${RESTORELIST}" | tr ',' '\n' > $TMPRESTOREFILE
 
 # Check if we've enabled the option to keep the full file path, and setup our restore string
-if [ "${RELKEEPPATH}" != "ON" ]
+if [ "${RELKEEPPATH}" = "ON" ]
 then
   ARGS="-R"
   SPACER="/."



More information about the Commits mailing list