From c127d97acf80136c2c4122d7c4bf5e3f28853272 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 8 Oct 2007 23:23:59 +0000 Subject: Allow configuration of the time to delete redundant store locations. --- bin/bbackupd/BackupDaemon.cpp | 12 +++++++----- bin/bbackupd/BackupDaemon.h | 2 ++ lib/backupclient/BackupDaemonConfigVerify.cpp | 1 + lib/backupclient/BackupStoreConstants.h | 9 --------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index b96f6225..ba844c87 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -876,6 +876,9 @@ void BackupDaemon::Run2() SecondsToBoxTime( conf.GetKeyValueInt( "MaxFileTimeInFuture")); + mDeleteRedundantLocationsAfter = + conf.GetKeyValueInt( + "DeleteRedundantLocationsAfter"); clientContext.SetMaximumDiffingTime(maximumDiffingTime); clientContext.SetKeepAliveTime(keepAliveTime); @@ -1659,7 +1662,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con for(std::list >::const_iterator i = rLocationsConf.mSubConfigurations.begin(); i != rLocationsConf.mSubConfigurations.end(); ++i) { - BOX_TRACE("new location"); + BOX_TRACE("new location: " << i->first); // Create a record for it Location *ploc = new Location; try @@ -1821,12 +1824,12 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con } catch (std::exception &e) { - delete ploc; - ploc = 0; BOX_ERROR("Failed to configure location '" << ploc->mName << "' path '" << ploc->mPath << "': " << e.what() << ": please check for previous errors"); + delete ploc; + ploc = 0; throw; } catch(...) @@ -1857,8 +1860,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con mDeleteUnusedRootDirEntriesAfter == 0) { mDeleteUnusedRootDirEntriesAfter = now + - SecondsToBoxTime( - BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER); + SecondsToBoxTime(mDeleteRedundantLocationsAfter); } int secs = BoxTimeToSeconds(mDeleteUnusedRootDirEntriesAfter diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h index ab64bbfa..580cbea6 100644 --- a/bin/bbackupd/BackupDaemon.h +++ b/bin/bbackupd/BackupDaemon.h @@ -158,6 +158,8 @@ private: std::vector mCurrentIDMaps; std::vector mNewIDMaps; + int mDeleteRedundantLocationsAfter; + // For the command socket class CommandSocketInfo { diff --git a/lib/backupclient/BackupDaemonConfigVerify.cpp b/lib/backupclient/BackupDaemonConfigVerify.cpp index 9000ec6d..61033b5b 100644 --- a/lib/backupclient/BackupDaemonConfigVerify.cpp +++ b/lib/backupclient/BackupDaemonConfigVerify.cpp @@ -77,6 +77,7 @@ static const ConfigurationVerifyKey verifyrootkeys[] = // return "now" if it's allowed, or a number of seconds if it's not {"MaximumDiffingTime", 0, ConfigTest_IsInt, 0}, + {"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0}, {"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, {"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, diff --git a/lib/backupclient/BackupStoreConstants.h b/lib/backupclient/BackupStoreConstants.h index 907072ea..2c33fd8f 100644 --- a/lib/backupclient/BackupStoreConstants.h +++ b/lib/backupclient/BackupStoreConstants.h @@ -40,14 +40,5 @@ // This is a multiple of the number of blocks in the diff from file. #define BACKUP_FILE_DIFF_MAX_BLOCK_FIND_MULTIPLE 4096 -// How many seconds to wait before deleting unused root directory entries? -#ifndef NDEBUG - // Debug: 30 seconds (easier to test) - #define BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER 30 -#else - // Release: 2 days (plenty of time for sysadmins to notice, or change their mind) - #define BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER 172800 -#endif - #endif // BACKUPSTORECONSTANTS__H -- cgit v1.2.3