summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing/finaltest.py
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-11-24 00:01:54 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-11-24 00:01:54 +0000
commitb17688b2c85a77e4f4eb45a928e915f8004b81a2 (patch)
tree267bf09d16a31d3557426d012d14454f676b0e0e /rdiff-backup/testing/finaltest.py
parenta326e28f5c73d5334abc4759dad12249cbcb7cf0 (diff)
downloadrdiff-backup-b17688b2c85a77e4f4eb45a928e915f8004b81a2.tar.gz
Restore excludes now leave existing files on target alone
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@497 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing/finaltest.py')
-rw-r--r--rdiff-backup/testing/finaltest.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/rdiff-backup/testing/finaltest.py b/rdiff-backup/testing/finaltest.py
index 5608220..26ff171 100644
--- a/rdiff-backup/testing/finaltest.py
+++ b/rdiff-backup/testing/finaltest.py
@@ -102,6 +102,20 @@ class PathSetter(unittest.TestCase):
print "Restoring via cmdline: " + cmdstr
assert not os.system(cmdstr)
+ def exec_rb_restore_extra_args(self, time, extra_args, *args):
+ """Like exec_rb_restore, but can provide extra arguments"""
+ arglist = []
+ arglist.append("--restore-as-of %s" % str(time))
+ arglist.append(extra_args)
+ arglist.append(self.src_prefix + args[0])
+ if len(args) > 1:
+ arglist.append(self.dest_prefix + args[1])
+ assert len(args) == 2
+
+ cmdstr = self.rb_schema + " ".join(arglist)
+ print "Restoring via cmdline: " + cmdstr
+ assert not os.system(cmdstr)
+
def delete_tmpdirs(self):
"""Remove any temp directories created by previous tests"""
assert not os.system(MiscDir + '/myrm testfiles/output* '
@@ -510,6 +524,49 @@ testfiles/increment2/changed_dir""")
self.assertRaises(OSError, os.lstat,
'testfiles/restoretarget1/executable2')
+ def testSelRestoreLocal(self):
+ """Test selection options when restoring locally"""
+ self.set_connections(None, None, None, None)
+ self.run_sel_restore_test()
+
+ def testSelRestoreRemote(self):
+ """Test selection options when both sides are remote"""
+ self.set_connections("test1/", "../", "test2/tmp/", "../../")
+ self.run_sel_restore_test("../../")
+
+ def run_sel_restore_test(self, prefix = ""):
+ """Test selection options with restore"""
+ self.make_restore_sel_dir()
+ existing_file = self.make_restore_existing_target()
+ file1_target = Local.rpout1.append("file1")
+ file2_target = Local.rpout1.append("file2")
+ excludes = ("--exclude %s --exclude %s --force" %
+ (prefix + file1_target.path, prefix + existing_file.path))
+ self.exec_rb_restore_extra_args("now", excludes,
+ Local.rpout.path, Local.rpout1.path)
+ for rp in (file1_target, file2_target, existing_file):
+ rp.setdata()
+ assert not file1_target.lstat(), file1_target.lstat()
+ assert file2_target.lstat()
+ assert existing_file.lstat() # excluded file shouldn't be deleted
+
+ def make_restore_sel_dir(self):
+ """Create rdiff-backup repository at Local.rpout"""
+ self.delete_tmpdirs()
+ Local.vft_in.mkdir()
+ rp1 = Local.vft_in.append("file1")
+ rp2 = Local.vft_in.append("file2")
+ rp1.touch()
+ rp2.touch()
+ self.exec_rb(None, Local.vft_in.path, Local.rpout.path)
+ Myrm(Local.vft_in.path)
+
+ def make_restore_existing_target(self):
+ """Create an existing file in the restore target directory"""
+ Local.rpout1.mkdir()
+ existing_file = Local.rpout1.append("existing_file")
+ existing_file.touch()
+ return existing_file
class FinalCorrupt(PathSetter):
"""Test messing with things a bit and making sure they still work"""