summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/selection.py
diff options
context:
space:
mode:
Diffstat (limited to 'rdiff-backup/rdiff_backup/selection.py')
-rw-r--r--rdiff-backup/rdiff_backup/selection.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py
index 6a02e24..e9476ac 100644
--- a/rdiff-backup/rdiff_backup/selection.py
+++ b/rdiff-backup/rdiff_backup/selection.py
@@ -234,6 +234,8 @@ class Select:
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":
@@ -471,6 +473,18 @@ probably isn't what you meant.""" %
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