[PC-BSD Commits] r6496 - in pcbsd/trunk/lifePreserver: . conf scripts
svn at pcbsd.org
svn at pcbsd.org
Fri Apr 2 10:36:30 PDT 2010
Author: kris
Date: 2010-04-02 10:36:30 -0700 (Fri, 02 Apr 2010)
New Revision: 6496
Added:
pcbsd/trunk/lifePreserver/conf/life-preserver.conf
pcbsd/trunk/lifePreserver/lifePreserverUserExclude.cpp
pcbsd/trunk/lifePreserver/lifePreserverUserExclude.h
pcbsd/trunk/lifePreserver/lifePreserverUserExclude.ui
Modified:
pcbsd/trunk/lifePreserver/lPreserve.pro
pcbsd/trunk/lifePreserver/lifePreserverSettings.cpp
pcbsd/trunk/lifePreserver/lifePreserverSettings.h
pcbsd/trunk/lifePreserver/lifePreserverSettings.ui
pcbsd/trunk/lifePreserver/preserver.cpp
pcbsd/trunk/lifePreserver/preserver.h
pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh
pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh
pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh
Log:
Large update to Life Preserver:
* Added functionality to change remote directory we will backup into
* Added new "User Excludes" ability, each preserver can be setup with a list of excludes for
that backup
Modified: pcbsd/trunk/lifePreserver/lPreserve.pro
===================================================================
--- pcbsd/trunk/lifePreserver/lPreserve.pro 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/lPreserve.pro 2010-04-02 17:36:30 UTC (rev 6496)
@@ -11,6 +11,7 @@
lifePreserverRestore.h \
lifePreserverRestoreProgress.h \
lifePreserverListbackups.h \
+ lifePreserverUserExclude.h \
preserver.h
SOURCES += main.cpp \
@@ -20,6 +21,7 @@
lifePreserverRestore.cpp \
lifePreserverRestoreProgress.cpp \
lifePreserverListBackups.cpp \
+ lifePreserverUserExclude.cpp \
preserver.cpp
RESOURCES += lPreserve.qrc
@@ -29,6 +31,7 @@
lifePreserverSettings.ui \
lifePreserverRestore.ui \
lifePreserverRestoreProgress.ui \
+ lifePreserverUserExclude.ui \
lifePreserverListBackups.ui
#DESTDIR = /usr/local/kde4/bin
@@ -52,7 +55,7 @@
images.files=images/lifepreserver.png
conf.path=/usr/PCBSD/lifePreserver/conf
-conf.files=conf/rsync-excludes
+conf.files=conf/*
desktop.path=/usr/local/kde4/share/applications/kde4
desktop.files=lifepreserver.desktop
Modified: pcbsd/trunk/lifePreserver/lifePreserverSettings.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverSettings.cpp 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/lifePreserverSettings.cpp 2010-04-02 17:36:30 UTC (rev 6496)
@@ -50,6 +50,7 @@
// Connect our slots for complete status checking
connect(pushOK,SIGNAL(clicked()),this,SLOT(slotOK()));
connect(pushCancel,SIGNAL(clicked()),this,SLOT(slotCancel()));
+ connect(pushExcludeList,SIGNAL(clicked()),this,SLOT(slotModifyExcludes()));
connect(radioDisable,SIGNAL(clicked()),this,SLOT(slotRadioChanged()));
connect(radioDaily,SIGNAL(clicked()),this,SLOT(slotRadioChanged()));
connect(radioWeekly,SIGNAL(clicked()),this,SLOT(slotRadioChanged()));
@@ -57,6 +58,7 @@
// Set our values for this preserver
spinNumBackups->setValue(editPreserver->getNumBackups());
checkCleanupFailed->setChecked(editPreserver->getFailedCleanup());
+ lineRemoteDir->setText(editPreserver->getRemoteDir());
QString cron = editPreserver->getCronSettings();
if ( cron == "disabled" )
{
@@ -96,6 +98,14 @@
}
+// Open the exclude dialog for this preserver
+void pSettings::slotModifyExcludes()
+{
+ pUserExclude *editExclude = new pUserExclude();
+ editExclude->widgetInit(editPreserver->getHost());
+ editExclude->show();
+}
+
// Save the config to disk
void pSettings::savePreserver()
{
@@ -104,6 +114,7 @@
editPreserver->setNumBackups(spinNumBackups->value());
editPreserver->setFailedCleanup(checkCleanupFailed->isChecked());
+ editPreserver->setRemoteDir(lineRemoteDir->text());
// Check if we've disabled cron
if ( radioDisable->isChecked() )
Modified: pcbsd/trunk/lifePreserver/lifePreserverSettings.h
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverSettings.h 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/lifePreserverSettings.h 2010-04-02 17:36:30 UTC (rev 6496)
@@ -10,6 +10,10 @@
#include "ui_lifePreserverSettings.h"
#include "preserver.h"
+#include "ui_lifePreserverUserExclude.h"
+#include "lifePreserverUserExclude.h"
+
+
/* KDE */
class pSettings : public QDialog, private Ui::pSettings
@@ -31,10 +35,12 @@
void slotOK();
void slotCancel();
void slotRadioChanged();
+ void slotModifyExcludes();
private:
void savePreserver();
PRESERVER *editPreserver;
+ pUserExclude *editExclude;
signals:
Modified: pcbsd/trunk/lifePreserver/lifePreserverSettings.ui
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverSettings.ui 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/lifePreserverSettings.ui 2010-04-02 17:36:30 UTC (rev 6496)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>445</width>
- <height>320</height>
+ <height>357</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,7 @@
<iconset resource="lPreserve.qrc">
<normaloff>:/images/images/lifepreserver.png</normaloff>:/images/images/lifepreserver.png</iconset>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
+ <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="groupOptions">
<property name="title">
@@ -63,20 +63,7 @@
<property name="title">
<string>Scheduled Backups</string>
</property>
- <layout class="QGridLayout" name="gridLayout_8">
- <item row="1" column="0">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>48</width>
- <height>74</height>
- </size>
- </property>
- </spacer>
- </item>
+ <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
@@ -283,10 +270,85 @@
</item>
</layout>
</item>
+ <item row="1" column="0">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>48</width>
+ <height>74</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
<item row="2" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Remote Directory</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QLineEdit" name="lineRemoteDir"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>418</width>
+ <height>13</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="pushExcludeList">
+ <property name="text">
+ <string>Modify Exclude List</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>418</width>
+ <height>13</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
@@ -306,6 +368,10 @@
<property name="text">
<string>&OK</string>
</property>
+ <property name="icon">
+ <iconset resource="lPreserve.qrc">
+ <normaloff>:/images/images/configure.png</normaloff>:/images/images/configure.png</iconset>
+ </property>
</widget>
</item>
<item>
@@ -313,6 +379,10 @@
<property name="text">
<string>&Cancel</string>
</property>
+ <property name="icon">
+ <iconset resource="lPreserve.qrc">
+ <normaloff>:/images/images/application-exit.png</normaloff>:/images/images/application-exit.png</iconset>
+ </property>
</widget>
</item>
</layout>
Modified: pcbsd/trunk/lifePreserver/preserver.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/preserver.cpp 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/preserver.cpp 2010-04-02 17:36:30 UTC (rev 6496)
@@ -201,6 +201,74 @@
return getConfValue("port").toInt();
}
+// Function which returns the remote backup dir
+QString PRESERVER::getRemoteDir()
+{
+ QString result = "life-preserver";
+
+ // Read in the result file
+ QFile File( LIFEPRESERVERSDIR + "/" + connectHost + "/remote-dir" );
+ if ( File.open( QIODevice::ReadOnly ) )
+ {
+ QTextStream stream( &File );
+ QString line;
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ // Return the first line
+ return line;
+ }
+ File.close();
+ }
+ return result;
+}
+
+// Function which sets the remote backup dir
+void PRESERVER::setRemoteDir(QString remoteDir)
+{
+ // Read in the result file
+ QFile File( LIFEPRESERVERSDIR + "/" + connectHost + "/remote-dir" );
+ if ( File.open( QIODevice::WriteOnly ) )
+ {
+ QTextStream streamout( &File );
+ streamout << remoteDir;
+ File.close();
+ }
+}
+
+// Function which returns the remote backup dir
+QStringList PRESERVER::getUserExcludes()
+{
+ QStringList excludes;
+ // Read in the result file
+ QFile File( LIFEPRESERVERSDIR + "/" + connectHost + "/exclude-list" );
+ if ( File.open( QIODevice::ReadOnly ) )
+ {
+ QTextStream stream( &File );
+ QString line;
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ excludes << line;
+ }
+ File.close();
+ }
+
+ return excludes;
+}
+
+// Function which returns the remote backup dir
+void PRESERVER::setUserExcludes(QStringList excludes)
+{
+ // Save the updated config
+ QFile File( LIFEPRESERVERSDIR + "/" + connectHost + "/exclude-list" );
+ if ( File.open( QIODevice::WriteOnly ) )
+ {
+ QTextStream streamout( &File );
+ for (int i = 0; i < excludes.size(); ++i)
+ streamout << excludes.at(i) << "\n";
+ File.close();
+ }
+}
+
// Function which returns the last backup status + date
QString PRESERVER::getLastBackup()
{
@@ -217,6 +285,7 @@
// Return the first line
return line;
}
+ pidFile.close();
}
return result;
@@ -406,9 +475,7 @@
QDir newPreserverDir;
newPreserverDir.setPath(LIFEPRESERVERSDIR + "/" + connectHost);
if ( ! newPreserverDir.exists() )
- {
newPreserverDir.mkpath(newPreserverDir.path());
- }
// Read in the old config and change the target key
QFile confFile( newPreserverDir.path() + "/settings.conf" );
@@ -431,18 +498,14 @@
// If we didn't find this key, add it in
if (!found)
- {
updatedConf << key + ": " + value.toString();
- }
// Save the updated config
if ( confFile.open( QIODevice::WriteOnly ) )
{
QTextStream streamout( &confFile );
for (int i = 0; i < updatedConf.size(); ++i)
- {
streamout << updatedConf.at(i) << "\n";
- }
confFile.close();
}
Modified: pcbsd/trunk/lifePreserver/preserver.h
===================================================================
--- pcbsd/trunk/lifePreserver/preserver.h 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/preserver.h 2010-04-02 17:36:30 UTC (rev 6496)
@@ -46,6 +46,8 @@
virtual int getPID();
virtual bool getFailedCleanup();
virtual QString getPreserverString();
+ virtual QString getRemoteDir();
+ virtual QStringList getUserExcludes();
//Setters
virtual void setHost(QString userhost);
@@ -55,6 +57,8 @@
virtual void setCron(QString hour);
virtual void setCron(QString hour, QString day);
virtual void setFailedCleanup(bool enabled);
+ virtual void setRemoteDir(QString remoteDir);
+ virtual void setUserExcludes(QStringList excludes);
// Other Functions which take actions
virtual void remove();
Modified: pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/scripts/backup-rsync.sh 2010-04-02 17:36:30 UTC (rev 6496)
@@ -12,24 +12,37 @@
DATE=`date "+%Y-%m-%dT%H_%M_%S"`
PROGDIR="/PCBSD/lifePreserver"
HOSTDIR="${PROGDIR}/preservers/${SSHHOST}"
-BACKDIR="life-preserver"
BACKLOG="${HOSTDIR}/logs/${DATE}.log"
EXCLUDELIST="/PCBSD/lifePreserver/conf/rsync-excludes"
+USEREXCLUDELIST="${HOSTDIR}/exclude-list"
+TMPEXCLUDELIST="${HOSTDIR}/.working-exclude-list"
PIDFILE="${HOSTDIR}/preserver.pid"
RESULTFILE="${HOSTDIR}/last-result"
STARTDATE=`date "+%H:%M %m-%d-%y"`
SETTINGS="${HOSTDIR}/settings.conf"
# Source our functions
+. ${PROGDIR}/conf/life-preserver.conf
. ${PROGDIR}/scripts/functions.sh
+if [ -e "${HOSTDIR}/remote-dir" ] ; then
+ BACKDIR="`cat ${HOSTDIR}/remote-dir`"
+else
+ BACKDIR="${DEFAULT_BACKDIR}"
+fi
+
# Make sure we've been given a valid life preserver
-if [ ! -d "${HOSTDIR}" ]
-then
+if [ ! -d "${HOSTDIR}" ] ; then
echo "ERROR: Invalid preserver: ${SSHHOST}"
exit 1
fi
+# Copy over the exclude files to our working list
+cp ${EXCLUDELIST} ${TMPEXCLUDELIST}
+if [ -e "${USEREXCLUDELIST}" ] ; then
+ cat ${EXCLUDELIST} ${USEREXCLUDELIST} > ${TMPEXCLUDELIST}
+fi
+
# Start by reading in some settings from the config
get_setting ${SETTINGS} "keepbackups"
KEEPNUM="${VAL}"
@@ -39,22 +52,18 @@
CLEANFAILED="${VAL}"
# Make sure we have a sane port number
-if [ -z "${PORT}" ]
-then
+if [ -z "${PORT}" ] ; then
PORT="22"
fi
-
# Make sure this host has its logs dir
-if [ ! -d "${HOSTDIR}/logs" ]
-then
+if [ ! -d "${HOSTDIR}/logs" ] ; then
mkdir ${HOSTDIR}/logs
fi
# Save the PID of this running process
check_pid ${PIDFILE}
-if [ "$?" = "1" ]
-then
+if [ "$?" = "1" ] ; then
echo "Failed: ${STARTDATE}" >${RESULTFILE}
echo "Failed: Backup already running? PID: $PID" >${BACKLOG}
exit 150
@@ -71,7 +80,7 @@
--rsync-path="rsync --fake-super" \
--perms --chmod=o-t \
--log-file=${BACKLOG} \
- --exclude-from ${EXCLUDELIST} \
+ --exclude-from ${TMPEXCLUDELIST} \
-e "ssh -p ${PORT}" \
--link-dest=../current \
/ ${SSHHOST}:${BACKDIR}/incomplete_back-$DATE
Modified: pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/scripts/list-backup-rsync.sh 2010-04-02 17:36:30 UTC (rev 6496)
@@ -11,11 +11,11 @@
PROGDIR="/PCBSD/lifePreserver"
HOSTDIR="${PROGDIR}/preservers/${SSHHOST}"
-BACKDIR="life-preserver"
PIDFILE="${HOSTDIR}/preserver.pid"
SETTINGS="${HOSTDIR}/settings.conf"
# Source our functions
+. ${PROGDIR}/conf/life-preserver.conf
. ${PROGDIR}/scripts/functions.sh
# Make sure we've been given a valid life preserver
@@ -25,6 +25,12 @@
exit 1
fi
+if [ -e "${HOSTDIR}/remote-dir" ] ; then
+ BACKDIR="`cat ${HOSTDIR}/remote-dir`"
+else
+ BACKDIR="${DEFAULT_BACKDIR}"
+fi
+
# Start by reading in some settings from the config
get_setting ${SETTINGS} "port"
PORT="${VAL}"
Modified: pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh
===================================================================
--- pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh 2010-04-02 16:41:05 UTC (rev 6495)
+++ pcbsd/trunk/lifePreserver/scripts/restore-rsync.sh 2010-04-02 17:36:30 UTC (rev 6496)
@@ -18,11 +18,11 @@
PROGDIR="/PCBSD/lifePreserver"
HOSTDIR="${PROGDIR}/preservers/${SSHHOST}"
-BACKDIR="life-preserver"
SETTINGS="${HOSTDIR}/settings.conf"
RESTORESH="${HOSTDIR}/.restoreCMD.$$"
# Source our functions
+. ${PROGDIR}/conf/life-preserver.conf
. ${PROGDIR}/scripts/functions.sh
# Make sure we've been given a valid life preserver
@@ -32,6 +32,12 @@
exit 1
fi
+if [ -e "${HOSTDIR}/remote-dir" ] ; then
+ BACKDIR="`cat ${HOSTDIR}/remote-dir`"
+else
+ BACKDIR="${DEFAULT_BACKDIR}"
+fi
+
# Start by reading in some settings from the config
get_setting ${SETTINGS} "port"
PORT="${VAL}"
More information about the Commits
mailing list