summaryrefslogtreecommitdiff
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
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
-rw-r--r--rdiff-backup/CHANGELOG5
-rw-r--r--rdiff-backup/rdiff-backup.121
-rw-r--r--rdiff-backup/rdiff_backup/Main.py26
-rw-r--r--rdiff-backup/rdiff_backup/selection.py47
-rw-r--r--rdiff-backup/testing/selectiontest.py8
5 files changed, 85 insertions, 22 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index 7235191..8743484 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,4 +1,4 @@
-New in v0.13.5 (2004/??/??)
+New in v0.13.5 (2005/??/??)
---------------------------
Added error-correcting fsync suggestion by Antoine Perdaens.
@@ -28,6 +28,9 @@ suggestion by David Vasilevsky
Dean Gaudet's patch fixes "--restrict /" option.
+Added Robert Shaw's --exclude-fifo, --include-symbolic-links,
+etc. options.
+
New in v0.13.4 (2004/01/31)
---------------------------
diff --git a/rdiff-backup/rdiff-backup.1 b/rdiff-backup/rdiff-backup.1
index 3be68e0..9894459 100644
--- a/rdiff-backup/rdiff-backup.1
+++ b/rdiff-backup/rdiff-backup.1
@@ -101,6 +101,9 @@ section for more information.
Exclude all device files. This can be useful for security/permissions
reasons or if rdiff-backup is not handling device files correctly.
.TP
+.B "--exclude-fifo-files"
+Exclude all fifo files.
+.TP
.BI "--exclude-filelist " filename
Excludes the files listed in
.IR filename .
@@ -141,7 +144,13 @@ See the
section for more information.
.TP
.B --exclude-special-files
-Exclude all device files, fifos, sockets, and symlinks.
+Exclude all device files, fifo files, socket files, and symbolic links.
+.TP
+.B "--exclude-socket-files"
+Exclude all socket files.
+.TP
+.B "--exclude-symbolic-links"
+Exclude all symbolic links.
.TP
.B --force
Authorize the updating or overwriting of a destination path.
@@ -198,6 +207,12 @@ will be included by this option. See the
.B FILE SELECTION
section for more information.
.TP
+.B --include-special-files
+Include all device files, fifo files, socket files, and symbolic links.
+.TP
+.B --include-symbolic-links
+Include all symbolic links.
+.TP
.BI "--list-at-time " time
List the files in the archive that were present at the given time. If
a directory in the archive is specified, list only the files under
@@ -546,7 +561,9 @@ and easy-to-use.
The file selection system comprises a number of file
selection conditions, which are set using one of the following command
line options:
-.BR --exclude , --exclude-device-files , --exclude-filelist ,
+.BR --exclude , --exclude-filelist ,
+.BR --exclude-device-files , --exclude-fifo-files ,
+.BR --exclude-socket-files , --exclude-symbolic-links ,
.BR --exclude-globbing-filelist ,
.BR --exclude-filelist-stdin , --exclude-regexp , --exclude-special-files ,
.BR --include ,
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
diff --git a/rdiff-backup/testing/selectiontest.py b/rdiff-backup/testing/selectiontest.py
index 2e0cd78..228d5b2 100644
--- a/rdiff-backup/testing/selectiontest.py
+++ b/rdiff-backup/testing/selectiontest.py
@@ -239,6 +239,14 @@ testfiles/select/1/1
assert sf2(fifo) == 0
assert sf2(sym) == 0
+ sf3 = self.Select.symlinks_get_sf(0)
+ assert sf3(dir) == None
+ assert sf3(reg) == None
+ assert sf3(dev) == None
+ assert sf3(sock) == None
+ assert sf3(fifo) == None
+ assert sf3(sym) == 0
+
def testRoot(self):
"""testRoot - / may be a counterexample to several of these.."""
root = rpath.RPath(Globals.local_connection, "/")