summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2006-11-05 01:36:23 +0000
committerdgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2006-11-05 01:36:23 +0000
commitcd8a54559e332a626029e6dee359217497bf010e (patch)
tree37c07315b2483e5287b97d902293a04e3d17143f
parentfece2fa190a8af5201353e06c59f8566b1bb5454 (diff)
downloadrdiff-backup-cd8a54559e332a626029e6dee359217497bf010e.tar.gz
--min-file-size/--max-file-size support. (Patch from Wout Mertens.)
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@761 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/CHANGELOG2
-rw-r--r--rdiff-backup/rdiff-backup.16
-rw-r--r--rdiff-backup/rdiff_backup/Main.py3
-rw-r--r--rdiff-backup/rdiff_backup/selection.py14
4 files changed, 25 insertions, 0 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index d176a70..1badf90 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,6 +1,8 @@
New in v1.1.6 (????/??/??)
--------------------------
+--min-file-size/--max-file-size support. (Patch from Wout Mertens.)
+
Mac OS X Extended Attributes support. (Patch from Andrew Ferguson.)
Preserve Mac OS X 'Creation Date' field across backups. (Patch from Andrew
diff --git a/rdiff-backup/rdiff-backup.1 b/rdiff-backup/rdiff-backup.1
index ad11db4..a968a05 100644
--- a/rdiff-backup/rdiff-backup.1
+++ b/rdiff-backup/rdiff-backup.1
@@ -283,6 +283,12 @@ to \-\-remove-older-than. Specifying a subdirectory is allowable; then
only the sizes of the mirror and increments pertaining to that
subdirectory will be listed.
.TP
+.BI "\-\-max-file-size " size
+Exclude files that are larger than the given size in bytes
+.TP
+.BI "\-\-min-file-size " size
+Exclude files that are smaller than the given size in bytes
+.TP
.B \-\-never-drop-acls
Exit with error instead of dropping acls or acl entries. Normally
this may happen (with a warning) because the destination does not
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index 90da372..bc648c7 100644
--- a/rdiff-backup/rdiff_backup/Main.py
+++ b/rdiff-backup/rdiff_backup/Main.py
@@ -75,6 +75,7 @@ def parse_cmdlineoptions(arglist):
"include-special-files", "include-symbolic-links",
"list-at-time=", "list-changed-since=", "list-increments",
"list-increment-sizes", "never-drop-acls",
+ "max-file-size=", "min-file-size=",
"no-acls", "no-carbonfile",
"no-compare-inode", "no-compression", "no-compression-regexp=",
"no-eas", "no-file-statistics", "no-hard-links", "null-separator",
@@ -152,6 +153,8 @@ def parse_cmdlineoptions(arglist):
elif opt == "-l" or opt == "--list-increments":
action = "list-increments"
elif opt == '--list-increment-sizes': action = 'list-increment-sizes'
+ elif opt == "--max-file-size": select_opts.append((opt, arg))
+ elif opt == "--min-file-size": select_opts.append((opt, arg))
elif opt == "--never-drop-acls": Globals.set("never_drop_acls", 1)
elif opt == "--no-acls": Globals.set("acls_active", 0)
elif opt == "--no-carbonfile": Globals.set("carbonfile_active", 0)
diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py
index bff1e0c..96b53aa 100644
--- a/rdiff-backup/rdiff_backup/selection.py
+++ b/rdiff-backup/rdiff_backup/selection.py
@@ -274,6 +274,10 @@ class Select:
self.add_selection_func(self.special_get_sf(1))
elif opt == "--include-symbolic-links":
self.add_selection_func(self.symlinks_get_sf(1))
+ elif opt == "--max-file-size":
+ self.add_selection_func(self.size_get_sf(1, arg))
+ elif opt == "--min-file-size":
+ self.add_selection_func(self.size_get_sf(0, arg))
else: assert 0, "Bad selection option %s" % opt
except SelectError, e: self.parse_catch_error(e)
assert filelists_index == len(filelists)
@@ -507,6 +511,16 @@ probably isn't what you meant.""" %
sel_func.name = (include and "include" or "exclude") + " special files"
return sel_func
+ def size_get_sf(self, min_max, sizestr):
+ """Return selection function given by filesize"""
+ size = int(sizestr)
+ assert size > 0
+ if min_max: sel_func = lambda rp: (rp.getsize() <= size)
+ else: sel_func = lambda rp: (rp.getsize() >= size)
+ sel_func.exclude = 1
+ sel_func.name = "%s size %d" % (min_max and "Maximum" or "Minimum", size)
+ return sel_func
+
def glob_get_sf(self, glob_str, include):
"""Return selection function given by glob string"""
assert include == 0 or include == 1