diff options
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r-- | rdiff-backup/rdiff_backup/Main.py | 22 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/restore.py | 16 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/selection.py | 7 |
3 files changed, 25 insertions, 20 deletions
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index 8cb817b..ef8440f 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -20,7 +20,7 @@ """Start (and end) here - read arguments, set global settings, etc.""" from __future__ import generators -import getopt, sys, re, os +import getopt, sys, re, os, cStringIO from log import Log, LoggerError, ErrorLog import Globals, Time, SetConnections, selection, robust, rpath, \ manage, backup, connection, restore, FilenameMapping, \ @@ -501,16 +501,26 @@ def restore_set_fs_globals(target): else: SetConnections.UpdateGlobal('chars_to_quote', "") def restore_set_select(mirror_rp, target): - """Set the selection iterator on mirror side from command line args + """Set the selection iterator on both side from command line args - Here we set the selector on the mirror side, because that is where - we will be filtering, but the pathnames are relative to the target - directory. + We must set both sides because restore filtering is different from + select filtering. For instance, if a file is excluded it should + not be deleted from the target directory. + + The StringIO stuff is because filelists need to be read and then + duplicated, because we need two copies of them now. """ + def fp2string(fp): + buf = fp.read() + assert not fp.close() + return buf + select_data = map(fp2string, select_files) if select_opts: mirror_rp.conn.restore.MirrorStruct.set_mirror_select( - target, select_opts, *select_files) + target, select_opts, *map(cStringIO.StringIO, select_data)) + target.conn.restore.TargetStruct.set_target_select( + target, select_opts, *map(cStringIO.StringIO, select_data)) def restore_start_log(rpin, target, time): """Open restore log file, log initial message""" diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py index 4a528ff..86795b1 100644 --- a/rdiff-backup/rdiff_backup/restore.py +++ b/rdiff-backup/rdiff_backup/restore.py @@ -25,11 +25,6 @@ import Globals, Time, Rdiff, Hardlink, rorpiter, selection, rpath, \ log, static, robust, metadata, statistics, TempFile, eas_acls -# This should be set to selection.Select objects over the source and -# mirror directories respectively. -_select_source = None -_select_mirror = None - # This will be set to the time of the current mirror _mirror_time = None # This will be set to the exact time to restore to (not restore_to_time) @@ -263,9 +258,16 @@ static.MakeClass(MirrorStruct) class TargetStruct: """Hold functions to be run on the target side when restoring""" - def get_initial_iter(cls, target): + _select = None + def set_target_select(cls, target, select_opts, *filelists): """Return a selection object iterating the rorpaths in target""" - return selection.Select(target).set_iter() + cls._select = selection.Select(target) + cls._select.ParseArgs(select_opts, filelists) + cls._select.set_iter() + + def get_initial_iter(cls, target): + """Return selector previously set with set_initial_iter""" + return cls._select or selection.Select(target).set_iter() def patch(cls, target, diff_iter): """Patch target with the diffs from the mirror side diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py index 0c6c548..b02c356 100644 --- a/rdiff-backup/rdiff_backup/selection.py +++ b/rdiff-backup/rdiff_backup/selection.py @@ -694,10 +694,3 @@ class FilterIterITRB(rorpiter.ITRBranch): assert s == 2, s self.base_queue = next_rorp - - - - - - - |