[Box Backup-dev] COMMIT r346 - in box/chris/bb-save-state: . bin/bbackupd lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Sat, 28 Jan 2006 14:32:30 +0000 (GMT)
Author: chris
Date: 2006-01-28 14:32:23 +0000 (Sat, 28 Jan 2006)
New Revision: 346
Modified:
box/chris/bb-save-state/bin/bbackupd/BackupDaemon.cpp
box/chris/bb-save-state/bin/bbackupd/bbackupd-config
box/chris/bb-save-state/configure.ac
box/chris/bb-save-state/lib/common/Archive.h
Log:
* configure.ac
- Reorganised header detection, added a few new ones for BackupDaemon.cpp
* lib/common/Archive.h
- This is the position you should adopt when you hear the words "Brace, Brace!"
* bin/bbackupd/BackupDaemon.cpp
- Delete the archive file when we've successfully loaded it. As Ben pointed
out, if we crash during a backup, the archive is invalid and we must not
try to use it.
- Replaced #ifndef WIN32 with autoconfiscated goodness(TM)
- Log message cleanup
* bin/bbackupd/bbackupd-config
- Added comments and example for StoreObjectInfoFile, disabled by default
* Pink Floyd
- Is there anybody out there?
Modified: box/chris/bb-save-state/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/bb-save-state/bin/bbackupd/BackupDaemon.cpp 2006-01-28 14:19:34 UTC (rev 345)
+++ box/chris/bb-save-state/bin/bbackupd/BackupDaemon.cpp 2006-01-28 14:32:23 UTC (rev 346)
@@ -10,12 +10,19 @@
#include "Box.h"
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
-#ifndef WIN32
+#ifdef HAVE_SIGNAL_H
#include <signal.h>
+#endif
+#ifdef HAVE_SYSLOG_H
#include <syslog.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
@@ -2172,23 +2179,36 @@
//
//
//
- if(!GetConfiguration().KeyExists("StoreObjectInfoFile") || GetConfiguration().GetKeyValue("StoreObjectInfoFile").size() <=0)
+ if(!GetConfiguration().KeyExists("StoreObjectInfoFile"))
+ {
return;
+ }
+ std::string StoreObjectInfoFile =
+ GetConfiguration().GetKeyValue("StoreObjectInfoFile");
+
+ if (StoreObjectInfoFile.size() <= 0)
+ {
+ return;
+ }
+
try
{
- FileStream aFile(GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str(), O_RDONLY);
+ FileStream aFile(StoreObjectInfoFile.c_str(), O_RDONLY);
IOStreamArchive anArchive(aFile, 0);
//
- // see if the content has a chance to be what we think it is
+ // see if the content looks like a valid serialised archive
//
int iMagicValue = 0;
anArchive.Get(iMagicValue);
if (iMagicValue != STOREOBJECTINFO_MAGIC_ID_VALUE)
{
- ::syslog(LOG_WARNING, "Store object info file '%s' is not what you think it is: no harm done, will re-cache from store", GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str());
+ ::syslog(LOG_WARNING, "Store object info file '%s' "
+ "is not a valid or compatible serialised "
+ "archive. Will re-cache from store.",
+ StoreObjectInfoFile.c_str());
return;
}
@@ -2200,31 +2220,42 @@
if (strMagicValue != STOREOBJECTINFO_MAGIC_ID_STRING)
{
- ::syslog(LOG_WARNING, "Store object info file '%s' is not what you think it is: no harm done, will re-cache from store", GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str());
+ ::syslog(LOG_WARNING, "Store object info file '%s' "
+ "is not a valid or compatible serialised "
+ "archive. Will re-cache from store.",
+ StoreObjectInfoFile.c_str());
return;
}
//
- // ok, check if we are not loading some future development version by mistake
+ // check if we are loading some future format
+ // version by mistake
//
int iVersion = 0;
anArchive.Get(iVersion);
if (iVersion != STOREOBJECTINFO_VERSION)
{
- ::syslog(LOG_WARNING, "Store object info file '%s' version [%d] unsupported: no harm done, will re-cache from store", GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str(), iVersion);
+ ::syslog(LOG_WARNING, "Store object info file '%s' "
+ "version [%d] unsupported. "
+ "Will re-cache from store.",
+ StoreObjectInfoFile.c_str(),
+ iVersion);
return;
}
//
- // check if this state file is even valid for the loaded bbackupd.conf file
+ // check if this state file is even valid
+ // for the loaded bbackupd.conf file
//
box_time_t lastKnownConfigModTime;
anArchive.Get(lastKnownConfigModTime);
if (lastKnownConfigModTime != GetConfiguration().GetModTime())
{
- ::syslog(LOG_WARNING, "Store object info file '%s' out of date: no harm done, will re-cache from store", GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str());
+ ::syslog(LOG_WARNING, "Store object info file '%s' "
+ "out of date. Will re-cache from store",
+ StoreObjectInfoFile.c_str());
return;
}
@@ -2267,16 +2298,29 @@
//
//
aFile.Close();
- ::syslog(LOG_INFO, "Loaded store object info file '%s', version [%04d]", GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str(), iVersion);
+ ::syslog(LOG_INFO, "Loaded store object info file '%s', "
+ "version [%d]", StoreObjectInfoFile.c_str(),
+ iVersion);
+
+ if (::unlink(StoreObjectInfoFile.c_str()) != 0)
+ {
+ ::syslog(LOG_ERR, "Failed to delete the old "
+ "store object info file '%s': %s",
+ StoreObjectInfoFile.c_str(), strerror(errno));
+ }
}
catch (...)
{
DeleteAllLocations();
- aClientStoreMarker = BackupClientContext::ClientStoreMarker_NotKnown;
+ aClientStoreMarker =
+ BackupClientContext::ClientStoreMarker_NotKnown;
theLastSyncTime = 0;
theNextSyncTime = 0;
- ::syslog(LOG_WARNING, "Requested store object info file '%s' does not exist, not accessible, or inconsistent: no harm done, will re-cache from store", GetConfiguration().GetKeyValue("StoreObjectInfoFile").c_str());
+ ::syslog(LOG_WARNING, "Requested store object info file '%s' "
+ "does not exist, not accessible, or inconsistent. "
+ "Will re-cache from store.",
+ StoreObjectInfoFile.c_str());
}
}
Modified: box/chris/bb-save-state/bin/bbackupd/bbackupd-config
===================================================================
--- box/chris/bb-save-state/bin/bbackupd/bbackupd-config 2006-01-28 14:19:34 UTC (rev 345)
+++ box/chris/bb-save-state/bin/bbackupd/bbackupd-config 2006-01-28 14:32:23 UTC (rev 346)
@@ -382,7 +382,15 @@
CommandSocket = /var/run/bbackupd.sock
+# Uncomment the StoreObjectInfoFile to enable the experimental archiving
+# of the daemon's state (including client store marker and configuration)
+# between backup runs. This saves time and increases efficiency when
+# bbackupd is frequently stopped and started, since it removes the need
+# to rescan all directories on the remote server. However, it is new and
+# not yet heavily tested, so use with caution.
+# StoreObjectInfoFile = /var/run/bbackupd.state
+
Server
{
PidFile = /var/run/bbackupd.pid
Modified: box/chris/bb-save-state/configure.ac
===================================================================
--- box/chris/bb-save-state/configure.ac 2006-01-28 14:19:34 UTC (rev 345)
+++ box/chris/bb-save-state/configure.ac 2006-01-28 14:32:23 UTC (rev 346)
@@ -74,8 +74,10 @@
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([execinfo.h netinet/in.h regex.h sys/types.h sys/xattr.h])
-AC_CHECK_HEADERS([sys/endian.h asm/byteorder.h])
+AC_CHECK_HEADERS([execinfo.h regex.h signal.h syslog.h])
+AC_CHECK_HEADERS([asm/byteorder.h])
+AC_CHECK_HEADERS([netinet/in.h])
+AC_CHECK_HEADERS([sys/endian.h sys/param.h sys/types.h sys/wait.h sys/xattr.h])
### Checks for typedefs, structures, and compiler characteristics.
Modified: box/chris/bb-save-state/lib/common/Archive.h
===================================================================
--- box/chris/bb-save-state/lib/common/Archive.h 2006-01-28 14:19:34 UTC (rev 345)
+++ box/chris/bb-save-state/lib/common/Archive.h 2006-01-28 14:32:23 UTC (rev 346)
@@ -124,9 +124,13 @@
Get(privItem);
if (privItem)
+ {
bItem = true;
+ }
else
+ {
bItem = false;
+ }
}
virtual void Get(int & iItem)
{