summaryrefslogtreecommitdiff
path: root/bin/bbackupd
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bbackupd')
-rw-r--r--bin/bbackupd/BackupClientContext.cpp18
-rw-r--r--bin/bbackupd/BackupClientDeleteList.cpp2
-rw-r--r--bin/bbackupd/BackupClientDirectoryRecord.cpp29
-rw-r--r--bin/bbackupd/BackupDaemon.cpp34
-rw-r--r--bin/bbackupd/BackupDaemon.h32
5 files changed, 61 insertions, 54 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp
index 6b51b9e8..7602ed29 100644
--- a/bin/bbackupd/BackupClientContext.cpp
+++ b/bin/bbackupd/BackupClientContext.cpp
@@ -25,7 +25,7 @@
#include "BackupStoreConstants.h"
#include "BackupStoreException.h"
#include "BackupDaemon.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
#include "BackupStoreFile.h"
#include "Logging.h"
@@ -165,7 +165,7 @@ BackupProtocolClient &BackupClientContext::GetConnection()
// Check the version of the server
{
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION));
+ std::auto_ptr<BackupProtocolVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION));
if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION)
{
THROW_EXCEPTION(BackupStoreException, WrongServerVersion)
@@ -173,7 +173,7 @@ BackupProtocolClient &BackupClientContext::GetConnection()
}
// Login -- if this fails, the Protocol will exception
- std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */));
+ std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */));
// Check that the client store marker is the one we expect
if(mClientStoreMarker != ClientStoreMarker_NotKnown)
@@ -419,20 +419,20 @@ bool BackupClientContext::FindFilename(int64_t ObjectID, int64_t ContainingDirec
// Request filenames from the server, in a "safe" manner to ignore errors properly
{
- BackupProtocolClientGetObjectName send(ObjectID, ContainingDirectory);
+ BackupProtocolGetObjectName send(ObjectID, ContainingDirectory);
connection.Send(send);
}
- std::auto_ptr<BackupProtocolObjectCl> preply(connection.Receive());
+ std::auto_ptr<BackupProtocolMessage> preply(connection.Receive());
// Is it of the right type?
- if(preply->GetType() != BackupProtocolClientObjectName::TypeID)
+ if(preply->GetType() != BackupProtocolObjectName::TypeID)
{
// Was an error or something
return false;
}
// Cast to expected type.
- BackupProtocolClientObjectName *names = (BackupProtocolClientObjectName *)(preply.get());
+ BackupProtocolObjectName *names = (BackupProtocolObjectName *)(preply.get());
// Anything found?
int32_t numElements = names->GetNumNameElements();
@@ -482,10 +482,10 @@ bool BackupClientContext::FindFilename(int64_t ObjectID, int64_t ContainingDirec
}
// Is it a directory?
- rIsDirectoryOut = ((names->GetFlags() & BackupProtocolClientListDirectory::Flags_Dir) == BackupProtocolClientListDirectory::Flags_Dir);
+ rIsDirectoryOut = ((names->GetFlags() & BackupProtocolListDirectory::Flags_Dir) == BackupProtocolListDirectory::Flags_Dir);
// Is it the current version?
- rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolClientListDirectory::Flags_OldVersion | BackupProtocolClientListDirectory::Flags_Deleted)) == 0);
+ rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolListDirectory::Flags_OldVersion | BackupProtocolListDirectory::Flags_Deleted)) == 0);
// And other information which may be required
if(pModTimeOnServer) *pModTimeOnServer = names->GetModificationTime();
diff --git a/bin/bbackupd/BackupClientDeleteList.cpp b/bin/bbackupd/BackupClientDeleteList.cpp
index b9b5b53e..c0414b78 100644
--- a/bin/bbackupd/BackupClientDeleteList.cpp
+++ b/bin/bbackupd/BackupClientDeleteList.cpp
@@ -13,7 +13,7 @@
#include "BackupClientDeleteList.h"
#include "BackupClientContext.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
#include "MemLeakFindOn.h"
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp
index b5c9fbcd..3f95be47 100644
--- a/bin/bbackupd/BackupClientDirectoryRecord.cpp
+++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp
@@ -17,7 +17,7 @@
#include <errno.h>
#include <string.h>
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
#include "Archive.h"
#include "BackupClientContext.h"
#include "BackupClientDirectoryRecord.h"
@@ -335,7 +335,7 @@ void BackupClientDirectoryRecord::SyncDirectory(
filename << ", nlink=" <<
file_st.st_nlink);
}
- else if(file_st.st_nlink != 1)
+ else if(file_st.st_nlink > 1)
{
if(!mSuppressMultipleLinksWarning)
{
@@ -613,10 +613,11 @@ BackupStoreDirectory *BackupClientDirectoryRecord::FetchDirectoryListing(BackupC
BackupProtocolClient &connection(rParams.mrContext.GetConnection());
// Query the directory
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(connection.QueryListDirectory(
+ std::auto_ptr<BackupProtocolSuccess> dirreply(connection.QueryListDirectory(
mObjectID,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, // both files and directories
- BackupProtocolClientListDirectory::Flags_Deleted | BackupProtocolClientListDirectory::Flags_OldVersion, // exclude old/deleted stuff
+ BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, // both files and directories
+ BackupProtocolListDirectory::Flags_Deleted |
+ BackupProtocolListDirectory::Flags_OldVersion, // exclude old/deleted stuff
true /* want attributes */));
// Retrieve the directory from the stream following
@@ -830,7 +831,8 @@ bool BackupClientDirectoryRecord::UpdateItems(
{
// Rename the existing files (ie include old versions) on the server
connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */,
- BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject,
+ BackupProtocolMoveObject::Flags_MoveAllWithSameName |
+ BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject,
storeFilename);
// Stop the attempt to delete the file in the original location
@@ -1364,7 +1366,8 @@ bool BackupClientDirectoryRecord::UpdateItems(
{
// Rename the existing directory on the server
connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */,
- BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject,
+ BackupProtocolMoveObject::Flags_MoveAllWithSameName |
+ BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject,
storeFilename);
// Put the latest attributes on it
@@ -1381,7 +1384,7 @@ bool BackupClientDirectoryRecord::UpdateItems(
else
{
// Create a new directory
- std::auto_ptr<BackupProtocolClientSuccess> dirCreate(connection.QueryCreateDirectory(
+ std::auto_ptr<BackupProtocolSuccess> dirCreate(connection.QueryCreateDirectory(
mObjectID, attrModTime, storeFilename, attrStream));
subDirObjectID = dirCreate->GetObjectID();
@@ -1577,7 +1580,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(
{
// YES -- try to do diff, if possible
// First, query the server to see if there's an old version available
- std::auto_ptr<BackupProtocolClientSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename));
+ std::auto_ptr<BackupProtocolSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename));
int64_t diffFromID = getBlockIndex->GetObjectID();
if(diffFromID != 0)
@@ -1625,7 +1628,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(
//
// Upload the patch to the store
//
- std::auto_ptr<BackupProtocolClientSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime,
+ std::auto_ptr<BackupProtocolSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime,
AttributesHash, isCompletelyDifferent?(0):(diffFromID), rStoreFilename, *pStreamToUpload));
// Get object ID from the result
@@ -1666,7 +1669,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(
}
// Send to store
- std::auto_ptr<BackupProtocolClientSuccess> stored(
+ std::auto_ptr<BackupProtocolSuccess> stored(
connection.QueryStoreFile(
mObjectID, ModificationTime,
AttributesHash,
@@ -1692,8 +1695,8 @@ int64_t BackupClientDirectoryRecord::UploadFile(
int type, subtype;
if(connection.GetLastError(type, subtype))
{
- if(type == BackupProtocolClientError::ErrorType
- && subtype == BackupProtocolClientError::Err_StorageLimitExceeded)
+ if(type == BackupProtocolError::ErrorType
+ && subtype == BackupProtocolError::Err_StorageLimitExceeded)
{
// The hard limit was exceeded on the server, notify!
rParams.mrSysadminNotifier.NotifySysadmin(
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index ccc52b8a..215c65a2 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -50,7 +50,7 @@
#include "SSLLib.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
#include "autogen_ClientException.h"
#include "autogen_ConversionException.h"
#include "Archive.h"
@@ -696,6 +696,7 @@ void BackupDaemon::RunSyncNowWithExceptionHandling()
// do not retry immediately without a good reason
mDoSyncForcedByPreviousSyncError = false;
+ // Notify system administrator about the final state of the backup
if(errorOccurred)
{
// Is it a berkely db failure?
@@ -757,16 +758,19 @@ void BackupDaemon::RunSyncNowWithExceptionHandling()
SYNC_PERIOD_RANDOM_EXTRA_TIME_SHIFT_BY);
}
}
- // Notify system administrator about the final state of the backup
- else if(mReadErrorsOnFilesystemObjects)
+
+ if(mReadErrorsOnFilesystemObjects)
{
NotifySysadmin(SysadminNotifier::ReadError);
}
- else if(mStorageLimitExceeded)
+
+ if(mStorageLimitExceeded)
{
NotifySysadmin(SysadminNotifier::StoreFull);
}
- else
+
+ if (!errorOccurred && !mReadErrorsOnFilesystemObjects &&
+ !mStorageLimitExceeded)
{
NotifySysadmin(SysadminNotifier::BackupOK);
}
@@ -1004,7 +1008,7 @@ void BackupDaemon::RunSyncNow()
#endif
(*i)->mpDirectoryRecord->SyncDirectory(params,
- BackupProtocolClientListDirectory::RootDirectory,
+ BackupProtocolListDirectory::RootDirectory,
locationPath, std::string("/") + (*i)->mName);
// Unset exclude lists (just in case)
@@ -2097,18 +2101,18 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
// Going to need a copy of the root directory. Get a connection,
// and fetch it.
- BackupProtocolClient &connection(rClientContext.GetConnection());
+ BackupProtocolCallable& connection(rClientContext.GetConnection());
// Ask server for a list of everything in the root directory,
// which is a directory itself
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(
+ std::auto_ptr<BackupProtocolSuccess> dirreply(
connection.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
+ BackupProtocolListDirectory::RootDirectory,
// only directories
- BackupProtocolClientListDirectory::Flags_Dir,
+ BackupProtocolListDirectory::Flags_Dir,
// exclude old/deleted stuff
- BackupProtocolClientListDirectory::Flags_Deleted |
- BackupProtocolClientListDirectory::Flags_OldVersion,
+ BackupProtocolListDirectory::Flags_Deleted |
+ BackupProtocolListDirectory::Flags_OldVersion,
false /* no attributes */));
// Retrieve the directory from the stream following
@@ -2348,9 +2352,9 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
try
{
MemBlockStream attrStream(attr);
- std::auto_ptr<BackupProtocolClientSuccess>
+ std::auto_ptr<BackupProtocolSuccess>
dirCreate(connection.QueryCreateDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
+ BackupProtocolListDirectory::RootDirectory,
attrModTime, dirname, attrStream));
// Object ID for later creation
@@ -2894,7 +2898,7 @@ void BackupDaemon::DeleteUnusedRootDirEntries(BackupClientContext &rContext)
// Entries to delete, and it's the right time to do so...
BOX_NOTICE("Deleting unused locations from store root...");
- BackupProtocolClient &connection(rContext.GetConnection());
+ BackupProtocolCallable &connection(rContext.GetConnection());
for(std::vector<std::pair<int64_t,std::string> >::iterator
i(mUnusedRootDirEntries.begin());
i != mUnusedRootDirEntries.end(); ++i)
diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h
index 23172f00..4a9097b9 100644
--- a/bin/bbackupd/BackupDaemon.h
+++ b/bin/bbackupd/BackupDaemon.h
@@ -24,7 +24,7 @@
#include "SocketStream.h"
#include "TLSContext.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
#ifdef WIN32
#include "WinNamedPipeListener.h"
@@ -382,7 +382,7 @@ public:
int type, int subtype)
{
std::ostringstream msgs;
- if (type != BackupProtocolClientError::ErrorType)
+ if (type != BackupProtocolError::ErrorType)
{
msgs << "unknown error type " << type;
}
@@ -390,46 +390,46 @@ public:
{
switch(subtype)
{
- case BackupProtocolClientError::Err_WrongVersion:
+ case BackupProtocolError::Err_WrongVersion:
msgs << "WrongVersion";
break;
- case BackupProtocolClientError::Err_NotInRightProtocolPhase:
+ case BackupProtocolError::Err_NotInRightProtocolPhase:
msgs << "NotInRightProtocolPhase";
break;
- case BackupProtocolClientError::Err_BadLogin:
+ case BackupProtocolError::Err_BadLogin:
msgs << "BadLogin";
break;
- case BackupProtocolClientError::Err_CannotLockStoreForWriting:
+ case BackupProtocolError::Err_CannotLockStoreForWriting:
msgs << "CannotLockStoreForWriting";
break;
- case BackupProtocolClientError::Err_SessionReadOnly:
+ case BackupProtocolError::Err_SessionReadOnly:
msgs << "SessionReadOnly";
break;
- case BackupProtocolClientError::Err_FileDoesNotVerify:
+ case BackupProtocolError::Err_FileDoesNotVerify:
msgs << "FileDoesNotVerify";
break;
- case BackupProtocolClientError::Err_DoesNotExist:
+ case BackupProtocolError::Err_DoesNotExist:
msgs << "DoesNotExist";
break;
- case BackupProtocolClientError::Err_DirectoryAlreadyExists:
+ case BackupProtocolError::Err_DirectoryAlreadyExists:
msgs << "DirectoryAlreadyExists";
break;
- case BackupProtocolClientError::Err_CannotDeleteRoot:
+ case BackupProtocolError::Err_CannotDeleteRoot:
msgs << "CannotDeleteRoot";
break;
- case BackupProtocolClientError::Err_TargetNameExists:
+ case BackupProtocolError::Err_TargetNameExists:
msgs << "TargetNameExists";
break;
- case BackupProtocolClientError::Err_StorageLimitExceeded:
+ case BackupProtocolError::Err_StorageLimitExceeded:
msgs << "StorageLimitExceeded";
break;
- case BackupProtocolClientError::Err_DiffFromFileDoesNotExist:
+ case BackupProtocolError::Err_DiffFromFileDoesNotExist:
msgs << "DiffFromFileDoesNotExist";
break;
- case BackupProtocolClientError::Err_DoesNotExistInDirectory:
+ case BackupProtocolError::Err_DoesNotExistInDirectory:
msgs << "DoesNotExistInDirectory";
break;
- case BackupProtocolClientError::Err_PatchConsistencyError:
+ case BackupProtocolError::Err_PatchConsistencyError:
msgs << "PatchConsistencyError";
break;
default: