I have a small contribution to make in the form of a simple selection 
function.

My company has found that we needed a way for users to say that particular 
directories shouldn't get backed up. The attached patch adds 
the --exclude-if-present option. It has been tested with 1.0.4 and 1.0.5.

I documented it on the wiki at 
http://wiki.rdiff-backup.org/wiki/index.php/ExcludeIfPresent .

Thanks,
Jeff Strunk
IT Administrator
Enthought, Inc.
Only in ./: build
diff -r -u ../rdiff-backup-1.0.5-orig/rdiff_backup/Main.py ./rdiff_backup/Main.py
--- ../rdiff-backup-1.0.5-orig/rdiff_backup/Main.py	2006-11-12 01:32:01.000000000 -0600
+++ ./rdiff_backup/Main.py	2007-03-13 11:06:34.000000000 -0500
@@ -62,7 +62,7 @@
 		  "exclude-symbolic-links", "exclude-sockets",
 		  "exclude-filelist-stdin", "exclude-globbing-filelist=",
 		  "exclude-globbing-filelist-stdin", "exclude-mirror=",
-		  "exclude-other-filesystems", "exclude-regexp=",
+		  "exclude-other-filesystems", "exclude-regexp=", "exclude-if-present=",
 		  "exclude-special-files", "force", "group-mapping-file=",
 		  "include=", "include-filelist=", "include-filelist-stdin",
 		  "include-globbing-filelist=",
@@ -99,6 +99,7 @@
 			  opt == "--exclude-fifos" or
 			  opt == "--exclude-other-filesystems" or
 			  opt == "--exclude-regexp" or
+			  opt == "--exclude-if-present" or
 			  opt == "--exclude-special-files" or
 			  opt == "--exclude-sockets" or
 			  opt == "--exclude-symbolic-links"):
Only in ./rdiff_backup: Main.py~
diff -r -u ../rdiff-backup-1.0.5-orig/rdiff_backup/selection.py ./rdiff_backup/selection.py
--- ../rdiff-backup-1.0.5-orig/rdiff_backup/selection.py	2006-11-12 01:32:01.000000000 -0600
+++ ./rdiff_backup/selection.py	2007-03-14 14:28:05.000000000 -0500
@@ -234,6 +234,8 @@
 			for opt, arg in argtuples:
 				if opt == "--exclude":
 					self.add_selection_func(self.glob_get_sf(arg, 0))
+				elif opt == "--exclude-if-present":
+					self.add_selection_func(self.presence_get_sf(arg, 0))
 				elif opt == "--exclude-device-files":
 					self.add_selection_func(self.devfiles_get_sf(0))
 				elif opt == "--exclude-symbolic-links":
@@ -467,6 +469,18 @@
 		sel_func.name = "Regular expression: %s" % regexp_string
 		return sel_func
 
+	def presence_get_sf(self, presence_filename, include):
+		"""Return selection function given by a file if present"""
+		assert include == 0 or include == 1
+
+		def sel_func(rp):
+                        if rp.isdir() and rp.readable() and rp.append(presence_filename).isreg(): return include
+			return None
+
+		sel_func.exclude = not include
+		sel_func.name = "Presence file: %s" % presence_filename
+		return sel_func
+
 	def gen_get_sf(self, pred, include, name):
 		"""Returns a selection function that uses pred to test
 		
Only in ./rdiff_backup: selection.py~
Only in ./rdiff_backup: selection.py.old
Only in ./: rdiffbackup.kdevelop
Only in ./: rdiffbackup.kdevses
_______________________________________________
rdiff-backup-users mailing list at [email protected]
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Reply via email to