summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-28 01:13:54 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-28 01:13:54 +0200
commit7b4540ae3c9ac331eed17fdf15a33f64b103cb4d (patch)
treeca47acead4e3676acd942de5f443d7bdc5fdd90c /bin
parent8a937bd354001a190dbe66538aacb353e7c99341 (diff)
Import upstream version 0.11.1~r2837
Diffstat (limited to 'bin')
-rw-r--r--bin/bbackupd/BackupClientContext.cpp2
-rw-r--r--bin/bbackupd/BackupClientContext.h4
-rw-r--r--bin/bbackupd/BackupClientDirectoryRecord.cpp12
-rw-r--r--bin/bbackupd/BackupDaemon.cpp11
-rw-r--r--bin/bbackupquery/BackupQueries.cpp49
-rw-r--r--bin/bbstored/BackupCommands.cpp11
-rw-r--r--bin/bbstored/BackupStoreContext.cpp22
-rwxr-xr-xbin/bbstored/bbstored-certs.in4
8 files changed, 68 insertions, 47 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp
index b978f54c..6b51b9e8 100644
--- a/bin/bbackupd/BackupClientContext.cpp
+++ b/bin/bbackupd/BackupClientContext.cpp
@@ -45,7 +45,7 @@ BackupClientContext::BackupClientContext
TLSContext &rTLSContext,
const std::string &rHostname,
int Port,
- int32_t AccountNumber,
+ uint32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
std::string ExtendedLogFile,
diff --git a/bin/bbackupd/BackupClientContext.h b/bin/bbackupd/BackupClientContext.h
index 4665df2b..404d2d77 100644
--- a/bin/bbackupd/BackupClientContext.h
+++ b/bin/bbackupd/BackupClientContext.h
@@ -45,7 +45,7 @@ public:
TLSContext &rTLSContext,
const std::string &rHostname,
int32_t Port,
- int32_t AccountNumber,
+ uint32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
std::string ExtendedLogFile,
@@ -213,7 +213,7 @@ private:
TLSContext &mrTLSContext;
std::string mHostname;
int mPort;
- int32_t mAccountNumber;
+ uint32_t mAccountNumber;
SocketStreamTLS *mpSocket;
BackupProtocolClient *mpConnection;
bool mExtendedLogging;
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp
index e03d53c2..84c17dab 100644
--- a/bin/bbackupd/BackupClientDirectoryRecord.cpp
+++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp
@@ -364,14 +364,14 @@ void BackupClientDirectoryRecord::SyncDirectory(
// Store on list
dirs.push_back(std::string(en->d_name));
}
- else if (type == S_IFSOCK || type == S_IFIFO)
- {
- // removed notification for these types
- // see Debian bug 479145, no objections
- }
else
{
- if(rParams.mrContext.ExcludeFile(filename))
+ if (type == S_IFSOCK || type == S_IFIFO)
+ {
+ // removed notification for these types
+ // see Debian bug 479145, no objections
+ }
+ else if(rParams.mrContext.ExcludeFile(filename))
{
rNotifier.NotifyFileExcluded(
this,
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index 5134d234..b6f90cad 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -743,7 +743,7 @@ void BackupDaemon::RunSyncNow()
mTlsContext,
conf.GetKeyValue("StoreHostname"),
conf.GetKeyValueInt("StorePort"),
- conf.GetKeyValueInt("AccountNumber"),
+ conf.GetKeyValueUint32("AccountNumber"),
conf.GetKeyValueBool("ExtendedLogging"),
conf.KeyExists("ExtendedLogFile"),
extendedLogFile, *mpProgressNotifier
@@ -1731,7 +1731,14 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
}
// Any entries in the root directory which need deleting?
- if(dir.GetNumberOfEntries() > 0)
+ if(dir.GetNumberOfEntries() > 0 &&
+ mDeleteRedundantLocationsAfter == 0)
+ {
+ BOX_NOTICE(dir.GetNumberOfEntries() << " redundant locations "
+ "in root directory found, but will not delete because "
+ "DeleteRedundantLocationsAfter = 0");
+ }
+ else if(dir.GetNumberOfEntries() > 0)
{
box_time_t now = GetCurrentBoxTime();
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index f799ab43..60724800 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -223,8 +223,8 @@ void BackupQueries::DoCommand(const char *Command, bool isFromCommandLine)
{ "restore", "drif" },
{ "help", "" },
{ "usage", "m" },
- { "undelete", "" },
- { "delete", "" },
+ { "undelete", "i" },
+ { "delete", "i" },
{ NULL, NULL }
};
@@ -324,8 +324,9 @@ void BackupQueries::DoCommand(const char *Command, bool isFromCommandLine)
case Command_pwd:
{
// Simple implementation, so do it here
- BOX_INFO(GetCurrentDirectoryName() << " (" <<
- BOX_FORMAT_OBJECTID(GetCurrentDirectoryID()));
+ BOX_NOTICE(GetCurrentDirectoryName() << " (" <<
+ BOX_FORMAT_OBJECTID(GetCurrentDirectoryID()) <<
+ ")");
}
break;
@@ -1008,8 +1009,7 @@ void BackupQueries::CommandGetObject(const std::vector<std::string> &args, const
// object ID, depending on opts['i'], where name can
// include a path) and return the file ID, placing the
// directory ID in *pDirIdOut and the filename part
-// of the path (if not looking up by ID and not NULL)
-// in *pFileNameOut.
+// of the path in *pFileNameOut (if not NULL).
// Created: 2008-09-12
//
// --------------------------------------------------------------------------
@@ -1039,11 +1039,6 @@ int64_t BackupQueries::FindFileID(const std::string& rNameOrIdString,
return 0;
}
}
-
- if(pFileNameOut)
- {
- *pFileNameOut = fileName;
- }
}
BackupStoreFilenameClear fn(fileName);
@@ -1106,6 +1101,12 @@ int64_t BackupQueries::FindFileID(const std::string& rNameOrIdString,
*pFlagsOut = en->GetFlags();
}
+ if(pFileNameOut)
+ {
+ BackupStoreFilenameClear entryName(en->GetName());
+ *pFileNameOut = entryName.GetClearFilename();
+ }
+
return fileId;
}
@@ -1862,7 +1863,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
for(std::set<std::pair<std::string, BackupStoreDirectory::Entry *> >::const_iterator i = storeDirs.begin(); i != storeDirs.end(); ++i)
{
std::string localPath(MakeFullPath(rLocalDir, i->first));
- std::string storePath(rLocalDir + "/" + i->first);
+ std::string storePath(rStoreDir + "/" + i->first);
// Does the directory exist locally?
string_set_iter_t local(localDirs.find(i->first));
@@ -1875,8 +1876,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
else if(local == localDirs.end())
{
// Not found -- report
- rParams.NotifyRemoteFileMissing(localPath,
- storePath, false);
+ rParams.NotifyLocalFileMissing(localPath,
+ storePath);
}
else if(rParams.IsExcludedDir(localPath))
{
@@ -1886,8 +1887,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
{
// Compare directory
Compare(i->second->GetObjectID(),
- rStoreDir + "/" + i->first,
- localPath, rParams);
+ storePath, localPath, rParams);
// Remove from set so that we know it's been compared
localDirs.erase(local);
@@ -1956,6 +1956,8 @@ void BackupQueries::CommandRestore(const std::vector<std::string> &args, const b
// Restoring deleted things?
bool restoreDeleted = opts['d'];
+ std::string storeDirEncoded;
+
// Get directory ID
int64_t dirID = 0;
if(opts['i'])
@@ -1967,15 +1969,17 @@ void BackupQueries::CommandRestore(const std::vector<std::string> &args, const b
BOX_ERROR("Not a valid object ID (specified in hex)");
return;
}
+ std::ostringstream oss;
+ oss << BOX_FORMAT_OBJECTID(args[0]);
+ storeDirEncoded = oss.str();
}
else
{
#ifdef WIN32
- std::string storeDirEncoded;
if(!ConvertConsoleToUtf8(args[0].c_str(), storeDirEncoded))
return;
#else
- const std::string& storeDirEncoded(args[0]);
+ storeDirEncoded = args[0];
#endif
// Look up directory ID
@@ -2008,9 +2012,14 @@ void BackupQueries::CommandRestore(const std::vector<std::string> &args, const b
try
{
+ // At TRACE level, we print a line for each file and
+ // directory, so we don't need dots.
+
+ bool printDots = ! Logging::IsEnabled(Log::TRACE);
+
result = BackupClientRestore(mrConnection, dirID,
- localName.c_str(),
- true /* print progress dots */, restoreDeleted,
+ storeDirEncoded.c_str(), localName.c_str(),
+ printDots /* print progress dots */, restoreDeleted,
false /* don't undelete after restore! */,
opts['r'] /* resume? */,
opts['f'] /* force continue after errors */);
diff --git a/bin/bbstored/BackupCommands.cpp b/bin/bbstored/BackupCommands.cpp
index 38cda234..c27cb7ab 100644
--- a/bin/bbstored/BackupCommands.cpp
+++ b/bin/bbstored/BackupCommands.cpp
@@ -388,11 +388,12 @@ std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProto
std::auto_ptr<IOStream> diff2(rContext.OpenObject(patchID));
// Choose a temporary filename for the result of the combination
- std::ostringstream fs(rContext.GetStoreRoot());
- fs << ".recombinetemp.";
- fs << p;
- std::string tempFn(fs.str());
- tempFn = RaidFileController::DiscSetPathToFileSystemPath(rContext.GetStoreDiscSet(), tempFn, p + 16);
+ std::ostringstream fs;
+ fs << rContext.GetStoreRoot() << ".recombinetemp." << p;
+ std::string tempFn =
+ RaidFileController::DiscSetPathToFileSystemPath(
+ rContext.GetStoreDiscSet(), fs.str(),
+ p + 16);
// Open the temporary file
std::auto_ptr<IOStream> combined;
diff --git a/bin/bbstored/BackupStoreContext.cpp b/bin/bbstored/BackupStoreContext.cpp
index 2e915f57..5ee13faa 100644
--- a/bin/bbstored/BackupStoreContext.cpp
+++ b/bin/bbstored/BackupStoreContext.cpp
@@ -11,21 +11,22 @@
#include <stdio.h>
+#include "BackupConstants.h"
#include "BackupStoreContext.h"
-#include "RaidFileWrite.h"
-#include "RaidFileRead.h"
+#include "BackupStoreDaemon.h"
#include "BackupStoreDirectory.h"
#include "BackupStoreException.h"
-#include "BackupStoreInfo.h"
-#include "BackupConstants.h"
#include "BackupStoreFile.h"
+#include "BackupStoreInfo.h"
#include "BackupStoreObjectMagic.h"
-#include "StoreStructure.h"
-#include "BackupStoreDaemon.h"
-#include "RaidFileController.h"
+#include "BufferedStream.h"
+#include "BufferedWriteStream.h"
#include "FileStream.h"
#include "InvisibleTempFileStream.h"
-#include "BufferedStream.h"
+#include "RaidFileController.h"
+#include "RaidFileRead.h"
+#include "RaidFileWrite.h"
+#include "StoreStructure.h"
#include "MemLeakFindOn.h"
@@ -919,7 +920,10 @@ void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir, int64_t Objec
{
RaidFileWrite writeDir(mStoreDiscSet, dirfn);
writeDir.Open(true /* allow overwriting */);
- rDir.WriteToStream(writeDir);
+
+ BufferedWriteStream buffer(writeDir);
+ rDir.WriteToStream(buffer);
+ buffer.Flush();
// get the disc usage (must do this before commiting it)
int64_t dirSize = writeDir.GetDiscUsageInBlocks();
diff --git a/bin/bbstored/bbstored-certs.in b/bin/bbstored/bbstored-certs.in
index e0554d94..85560748 100755
--- a/bin/bbstored/bbstored-certs.in
+++ b/bin/bbstored/bbstored-certs.in
@@ -1,8 +1,8 @@
#!@PERL@
use strict;
-# validity period for root certificates -- default is a very long time
-my $root_sign_period = '10000';
+# validity period for root certificates -- default is 2038, the best we can do for now
+my $root_sign_period = int(((1<<31) - time()) / 86400);
# but less so for client certificates
my $sign_period = '5000';