summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2011-03-27 01:02:19 +0000
committerChris Wilson <chris+github@qwirx.com>2011-03-27 01:02:19 +0000
commit2861c52020252f5095d3f82c995492ac330426c2 (patch)
tree1ca4addcc471a9fdaa41a45558e4f498d7da7317 /bin
parent0fe90245a77295226d0967bc0702e591afe2afa7 (diff)
Fix abort if the local data directory doesn't exist.
Diffstat (limited to 'bin')
-rw-r--r--bin/bbackupd/BackupDaemon.cpp61
-rw-r--r--bin/bbackupd/bbackupd.cpp2
2 files changed, 39 insertions, 24 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index ca7cdcc9..f14ca2fe 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -573,15 +573,14 @@ void BackupDaemon::Run2()
void BackupDaemon::RunSyncNowWithExceptionHandling()
{
- OnBackupStart();
-
- // Do sync
bool errorOccurred = false;
int errorCode = 0, errorSubCode = 0;
const char* errorString = "unknown";
try
{
+ OnBackupStart();
+ // Do sync
RunSyncNow();
}
catch(BoxException &e)
@@ -975,28 +974,35 @@ void BackupDaemon::OnBackupStart()
void BackupDaemon::OnBackupFinish()
{
- // Log
- BOX_NOTICE("Finished scan of local files");
-
- // Log the stats
- BOX_NOTICE("File statistics: total file size uploaded "
- << BackupStoreFile::msStats.mBytesInEncodedFiles
- << ", bytes already on server "
- << BackupStoreFile::msStats.mBytesAlreadyOnServer
- << ", encoded size "
- << BackupStoreFile::msStats.mTotalFileStreamSize);
-
- // Reset statistics again
- BackupStoreFile::ResetStats();
+ try
+ {
+ // Log
+ BOX_NOTICE("Finished scan of local files");
- // Notify administrator
- NotifySysadmin(SysadminNotifier::BackupFinish);
+ // Log the stats
+ BOX_NOTICE("File statistics: total file size uploaded "
+ << BackupStoreFile::msStats.mBytesInEncodedFiles
+ << ", bytes already on server "
+ << BackupStoreFile::msStats.mBytesAlreadyOnServer
+ << ", encoded size "
+ << BackupStoreFile::msStats.mTotalFileStreamSize);
- // Tell anything connected to the command socket
- SendSyncStartOrFinish(false /* finish */);
+ // Reset statistics again
+ BackupStoreFile::ResetStats();
- // Touch a file to record times in filesystem
- TouchFileInWorkingDir("last_sync_finish");
+ // Notify administrator
+ NotifySysadmin(SysadminNotifier::BackupFinish);
+
+ // Tell anything connected to the command socket
+ SendSyncStartOrFinish(false /* finish */);
+
+ // Touch a file to record times in filesystem
+ TouchFileInWorkingDir("last_sync_finish");
+ }
+ catch (std::exception &e)
+ {
+ BOX_ERROR("Failed to perform backup finish actions: " << e.what());
+ }
}
// --------------------------------------------------------------------------
@@ -2088,7 +2094,16 @@ void BackupDaemon::TouchFileInWorkingDir(const char *Filename)
fn += Filename;
// Open and close it to update the timestamp
- FileStream touch(fn.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ try
+ {
+ FileStream touch(fn, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR);
+ }
+ catch (std::exception &e)
+ {
+ BOX_ERROR("Failed to write to timestamp file: " << fn << ": " <<
+ e.what());
+ }
}
diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp
index 8313e193..bb64f745 100644
--- a/bin/bbackupd/bbackupd.cpp
+++ b/bin/bbackupd/bbackupd.cpp
@@ -41,7 +41,7 @@ int main(int argc, const char *argv[])
ExitCode = gpDaemonService->Daemon::Main(
BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE,
argc, argv);
- delete gpDaemonService;
+ delete gpDaemonService;
#else // !WIN32