summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-03-26 17:10:57 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-03-26 17:10:57 +0000
commit390f0eb37f3972adb1ff272acd28ea2d09c596da (patch)
tree9179f25208766b15213a424cea53e2e874dd80ef /rdiff-backup/rdiff_backup
parent62b94cab6043f6c55d8069c9af6c6423246e0375 (diff)
downloadrdiff-backup-390f0eb37f3972adb1ff272acd28ea2d09c596da.tar.gz
Added Robert Shaw's --exclude-fifo, --include-symbolic-links,
etc. options. git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@563 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r--rdiff-backup/rdiff_backup/Main.py26
-rw-r--r--rdiff-backup/rdiff_backup/selection.py47
2 files changed, 54 insertions, 19 deletions
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index c7bd469..059dae7 100644
--- a/rdiff-backup/rdiff_backup/Main.py
+++ b/rdiff-backup/rdiff_backup/Main.py
@@ -55,14 +55,17 @@ def parse_cmdlineoptions(arglist):
try: optlist, args = getopt.getopt(arglist, "blr:sv:V",
["backup-mode", "calculate-average", "check-destination-dir",
"compare", "compare-at-time=", "current-time=", "exclude=",
- "exclude-device-files", "exclude-filelist=",
- "exclude-filelist-stdin", "exclude-globbing-filelist=",
+ "exclude-device-files", "exclude-fifos",
+ "exclude-filelist=", "exclude-symbolic-links",
+ "exclude-sockets", "exclude-filelist-stdin",
+ "exclude-globbing-filelist=",
"exclude-globbing-filelist-stdin", "exclude-mirror=",
"exclude-other-filesystems", "exclude-regexp=",
"exclude-special-files", "force", "group-mapping-file=",
"include=", "include-filelist=", "include-filelist-stdin",
"include-globbing-filelist=",
"include-globbing-filelist-stdin", "include-regexp=",
+ "include-special-files", "include-symbolic-links",
"list-at-time=", "list-changed-since=", "list-increments",
"list-increment-sizes", "never-drop-acls", "no-acls",
"no-compare-inode", "no-compression",
@@ -87,8 +90,15 @@ def parse_cmdlineoptions(arglist):
else: restore_timestr = arg
elif opt == "--current-time":
Globals.set_integer('current_time', arg)
- elif opt == "--exclude": select_opts.append((opt, arg))
- elif opt == "--exclude-device-files": select_opts.append((opt, arg))
+ elif (opt == "--exclude" or
+ opt == "--exclude-device-files" or
+ opt == "--exclude-fifos" or
+ opt == "--exclude-other-filesystems" or
+ opt == "--exclude-regexp" or
+ opt == "--exclude-special-files" or
+ opt == "--exclude-sockets" or
+ opt == "--exclude-symbolic-links"):
+ select_opts.append((opt, arg))
elif opt == "--exclude-filelist":
select_opts.append((opt, arg))
select_files.append(sel_fl(arg))
@@ -102,12 +112,12 @@ def parse_cmdlineoptions(arglist):
select_opts.append(("--exclude-globbing-filelist",
"standard input"))
select_files.append(sys.stdin)
- elif (opt == "--exclude-other-filesystems" or
- opt == "--exclude-regexp" or
- opt == "--exclude-special-files"): select_opts.append((opt, arg))
elif opt == "--force": force = 1
elif opt == "--group-mapping-file": group_mapping_filename = arg
- elif opt == "--include": select_opts.append((opt, arg))
+ elif (opt == "--include" or
+ opt == "--include-special-files" or
+ opt == "--include-symbolic-links"):
+ select_opts.append((opt, arg))
elif opt == "--include-filelist":
select_opts.append((opt, arg))
select_files.append(sel_fl(arg))
diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py
index b02c356..88f9676 100644
--- a/rdiff-backup/rdiff_backup/selection.py
+++ b/rdiff-backup/rdiff_backup/selection.py
@@ -233,6 +233,12 @@ class Select:
self.add_selection_func(self.glob_get_sf(arg, 0))
elif opt == "--exclude-device-files":
self.add_selection_func(self.devfiles_get_sf(0))
+ elif opt == "--exclude-symbolic-links":
+ self.add_selection_func(self.symlinks_get_sf(0))
+ elif opt == "--exclude-sockets":
+ self.add_selection_func(self.sockets_get_sf(0))
+ elif opt == "--exclude-fifos":
+ self.add_selection_func(self.fifos_get_sf(0))
elif opt == "--exclude-filelist":
self.add_selection_func(self.filelist_get_sf(
filelists[filelists_index], 0, arg))
@@ -261,6 +267,10 @@ class Select:
filelists_index += 1
elif opt == "--include-regexp":
self.add_selection_func(self.regexp_get_sf(arg, 1))
+ elif opt == "--include-special-files":
+ self.add_selection_func(self.special_get_sf(1))
+ elif opt == "--include-symbolic-links":
+ self.add_selection_func(self.symlinks_get_sf(1))
else: assert 0, "Bad selection option %s" % opt
except SelectError, e: self.parse_catch_error(e)
assert filelists_index == len(filelists)
@@ -454,23 +464,38 @@ probably isn't what you meant.""" %
sel_func.name = "Regular expression: %s" % regexp_string
return sel_func
- def devfiles_get_sf(self, include):
- """Return a selection function matching all dev files"""
- if self.selection_functions:
- log.Log("Warning: exclude-device-files is not the first "
- "selector.\nThis may not be what you intended", 3)
+ def gen_get_sf(self, pred, include, name):
+ """Returns a selection function that uses pred to test
+
+ RPath is matched if pred returns true on it. Name is a string
+ summarizing the test to the user.
+
+ """
def sel_func(rp):
- if rp.isdev(): return include
- else: return None
+ if pred(rp): return include
+ return None
sel_func.exclude = not include
- sel_func.name = (include and "include" or "exclude") + " device files"
+ sel_func.name = (include and "include " or "exclude ") + name
return sel_func
+ def devfiles_get_sf(self, include):
+ """Return a selection function matching all dev files"""
+ return self.gen_get_sf(rpath.RORPath.isdev, include, "device files")
+
+ def symlinks_get_sf(self, include):
+ """Return a selection function matching all symlinks"""
+ return self.gen_get_sf(rpath.RORPath.issym, include, "symbolic links")
+
+ def sockets_get_sf(self, include):
+ """Return a selection function matching all sockets"""
+ return self.gen_get_sf(rpath.RORPath.issock, include, "socket files")
+
+ def fifos_get_sf(self, include):
+ """Return a selection function matching all fifos"""
+ return self.gen_get_sf(rpath.RORPath.isfifo, include, "fifo files")
+
def special_get_sf(self, include):
"""Return sel function matching sockets, symlinks, sockets, devs"""
- if self.selection_functions:
- log.Log("Warning: exclude-special-files is not the first "
- "selector.\nThis may not be what you intended", 3)
def sel_func(rp):
if rp.issym() or rp.issock() or rp.isfifo() or rp.isdev():
return include