[Box Backup] FeatureRequest: Mass Deletion Protection

Torsten boxbackup@fluffy.co.uk
Tue, 5 Aug 2008 16:23:24 +0200


--MP_u6wjIAi8BOol5HNGyo=4Ou3
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

i build a little patch for the Feature Request "Mass Deletion Protection".

http://boxbackup.org/trac/wiki/FeatureRequests#MassDeletionProtection

If a local directory does not exists but exists on the backup store. And if this location is activated in bbackupd.conf then it is not marked as deleted. 

I use this in conjunction with autofs and linux. Autofs does not create a directory if the mount was not successfully.

To activate this you have to extend the bbackupd.conf config file with:

KeepLocationIfNotFoundLocal = yes

It would be nice, if somebody could tell me if this patch works for you.

I don't know, if the mailing list filters attachments. If so, where to put the patch?

  Torsten
--MP_u6wjIAi8BOol5HNGyo=4Ou3
Content-Type: text/x-patch;
 name=boxbackup_mass_deletion_protection_r2216.diff
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=boxbackup_mass_deletion_protection_r2216.diff

Index: lib/backupclient/BackupDaemonConfigVerify.cpp
===================================================================
--- lib/backupclient/BackupDaemonConfigVerify.cpp	(Revision 2216)
+++ lib/backupclient/BackupDaemonConfigVerify.cpp	(Arbeitskopie)
@@ -105,6 +105,8 @@
 
 	ConfigurationVerifyKey("NotifyScript", 0),
 	// optional script to run when backup needs attention, eg store full
+
+	ConfigurationVerifyKey("KeepLocationIfNotFoundLocal", ConfigTest_IsBool, false),
 	
 	ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists),
 	ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists),
Index: bin/bbackupd/BackupDaemon.cpp
===================================================================
--- bin/bbackupd/BackupDaemon.cpp	(Revision 2216)
+++ bin/bbackupd/BackupDaemon.cpp	(Arbeitskopie)
@@ -40,6 +40,7 @@
 #endif
 
 #include <iostream>
+#include <fstream>
 
 #include "Configuration.h"
 #include "IOStream.h"
@@ -1220,6 +1221,23 @@
 		i(mLocations.begin()); 
 		i != mLocations.end(); ++i)
 	{
+		// KeepLocationIfNotFoundLocal
+		// Check if that directory exists local
+		// otherwise do not sync it
+		//if (conf.KeyExists("KeepLocationIfNotFound") &&
+		if (conf.GetKeyValueBool("KeepLocationIfNotFoundLocal"))
+		{
+			std::ifstream check((*i)->mPath.c_str() , std::ifstream::in);
+			if(!check)
+			{
+				BOX_WARNING("Local directory " << (*i)->mPath << 
+					" does not exist but exists on the server and is "
+					"specified as BackupLocation, so not deleting it "
+					"on backup store (KeepLocationIfNotFoundLocal = true).");
+				continue;
+			}
+		}
+
 		// Set current and new ID map pointers
 		// in the context
 		clientContext.SetIDMaps(mCurrentIDMaps[(*i)->mIDMapIndex],

--MP_u6wjIAi8BOol5HNGyo=4Ou3--