def testRemoveOlderThanCurrent(self): """Make sure --remove-older-than doesn't delete current incs""" Myrm(Local.rpout.path) assert not os.system(b"cp -a %b %b" % (Local.backup3rp.path, Local.rpout.path)) rdiff_backup(True, True, Local.rpout.path, None, extra_options=b"--remove-older-than now --force") rbdir = Local.rpout.append("rdiff-backup-data") has_cur_mirror, has_metadata = 0, 0 for inc in self.get_all_increments(rbdir): if inc.getincbase().index[-1] == b'current_mirror': has_cur_mirror = 1 elif inc.getincbase().index[-1] == b'mirror_metadata': has_metadata = 1 assert has_cur_mirror and has_metadata, (has_cur_mirror, has_metadata)
def run_sel_restore_test(self, source_local, dest_local): """Test selection options with restore""" self.make_restore_sel_dir(source_local, dest_local) existing_file = self.make_restore_existing_target() file1_target = Local.rpout1.append("file1") file2_target = Local.rpout1.append("file2") excludes = (b"--exclude %b --exclude %b --force" % (file1_target.path, existing_file.path)) rdiff_backup(source_local, dest_local, Local.rpout.path, Local.rpout1.path, extra_options=b"--restore-as-of now " + excludes) for rp in (file1_target, file2_target, existing_file): rp.setdata() self.assertFalse(file1_target.lstat()) self.assertTrue(file2_target.lstat()) # excluded file shouldn't be deleted: self.assertTrue(existing_file.lstat())
def test_restrict_updateonly_negative(self): """Test that --restrict-update-only impairs unintended""" Myrm(abs_output_dir) self.secure_rdiff_backup(self.various_files_dir, abs_output_dir, 1, b'--restrict-update-only %b' % abs_output_dir, success=0) Myrm(abs_output_dir) Myrm(abs_restore_dir) rdiff_backup(1, 1, self.various_files_dir, abs_output_dir) self.secure_rdiff_backup(abs_output_dir, abs_restore_dir, 1, b'--restrict-update-only %b' % abs_restore_dir, extra_args=b'-r now', success=0)
def test_long_socket_name(self): """Test when socket name is saved to a backup directory with a long name It addresses an issue where socket wasn't created with mknod but with socket.socket and bind, which has a limit at 107 characters.""" input_dir = os.path.join(old_test_dir, b"select", b"filetypes") # create a target directory with a long name next to 107 output_dir = os.path.join(abs_test_dir, b"tenletters" * 10) Myrm(output_dir) restore_dir = os.path.join(abs_test_dir, b"restoresme" * 10) Myrm(restore_dir) # backup and restore the input directory with socket, then compare rdiff_backup(True, True, input_dir, output_dir) rdiff_backup(True, True, output_dir, restore_dir, extra_options=b'-r 0') compare_recursive(rpath.RPath(Globals.local_connection, input_dir), rpath.RPath(Globals.local_connection, restore_dir))
def test_overlapping_dirs(self): """Test if we can backup a directory containing the backup repo while ignoring this repo""" testrp = rpath.RPath(Globals.local_connection, abs_test_dir).append('selection_overlap') re_init_rpath_dir(testrp) backuprp = testrp.append('backup') emptyrp = testrp.append('empty') # just to have something to backup emptyrp.mkdir() rdiff_backup(1, 1, testrp.path, backuprp.path, extra_options=b"--exclude %s" % backuprp.path) assert backuprp.append('rdiff-backup-data').isdir() and \ backuprp.append('empty').isdir(), \ "Backup to %s didn't happen properly." % backuprp.getsafepath()
def test_unreadable(self): """Run regress test when regular file is unreadable""" self.output_rp.setdata() if self.output_rp.lstat(): Myrm(self.output_rp.path) unreadable_rp = self.make_unreadable() rdiff_backup(1, 1, unreadable_rp.path, self.output_rp.path, current_time=1) rbdir = self.output_rp.append('rdiff-backup-data') marker = rbdir.append('current_mirror.2000-12-31T21:33:20-07:00.data') marker.touch() self.change_unreadable() cmd = b"rdiff-backup --check-destination-dir %s" % self.output_rp.path print("Executing:", cmd) self.assertEqual(os_system(cmd), 0)
def test_restrict_readonly_negative(self): """Test that --restrict-read-only doesn't allow too much""" # Backup to restricted directory Myrm(abs_output_dir) self.secure_rdiff_backup(self.various_files_dir, abs_output_dir, 1, b'--restrict-read-only %b' % abs_output_dir, success=0) # Restore to restricted directory Myrm(abs_output_dir) Myrm(abs_restore_dir) rdiff_backup(1, 1, self.various_files_dir, abs_output_dir) self.secure_rdiff_backup(abs_output_dir, abs_restore_dir, 1, b'--restrict-read-only %b' % abs_restore_dir, extra_args=b'-r now', success=0)
def generic_regress_test(self, extra_args): """Used for regress tests below""" in1, in2 = self.make_input_dirs() Myrm(self.out_rp.path) restore_dir = self.root_rp.append('longname_out') Myrm(restore_dir.path) rdiff_backup(1, 1, in1.path, self.out_rp.path, 10000, extra_options=extra_args) rdiff_backup(1, 1, in2.path, self.out_rp.path, 20000, extra_options=extra_args) # Regress repository back to in1 condition Globals.rbdir = self.out_rp.append_path('rdiff-backup-data') self.add_current_mirror(10000) self.out_rp.setdata() regress.Regress(self.out_rp) # Restore in1 and compare rdiff_backup(1, 1, self.out_rp.path, restore_dir.path, 30000, extra_options=b'-r now ' + extra_args) self.check_dir1(restore_dir)
def testLongFilenames(self): """See if long quoted filenames cause crash""" MakeOutputDir() outrp = rpath.RPath(Globals.local_connection, abs_output_dir) inrp = rpath.RPath(Globals.local_connection, os.path.join(abs_test_dir, b"quotetest")) re_init_rpath_dir(inrp) long_filename = b"A" * 200 # when quoted should cause overflow longrp = inrp.append(long_filename) longrp.touch() shortrp = inrp.append(b"B") shortrp.touch() rdiff_backup(1, 1, inrp.path, outrp.path, 100000, extra_options=b"--override-chars-to-quote A") longrp_out = outrp.append(long_filename) assert not longrp_out.lstat() shortrp_out = outrp.append('B') assert shortrp_out.lstat() rdiff_backup(1, 1, os.path.join(old_test_dir, b"empty"), outrp.path, 200000) shortrp_out.setdata() assert not shortrp_out.lstat() rdiff_backup(1, 1, inrp.path, outrp.path, 300000) shortrp_out.setdata() assert shortrp_out.lstat()
def test_numerical_mapping(self): """Test --preserve-numerical-ids option This doesn't really test much, since we don't have a convenient system with different uname/ids. """ def write_ownership_dir(): """Write the directory testfiles/root_mapping""" rp = rpath.RPath(Globals.local_connection, os.path.join(abs_test_dir, b"root_mapping")) re_init_rpath_dir(rp) rp1 = rp.append('1') rp1.touch() rp2 = rp.append('2') rp2.touch() rp2.chown(userid, 1) # use groupid 1, usually bin return rp def get_ownership(dir_rp): """Return pair (ids of dir_rp/1, ids of dir_rp2) of ids""" rp1, rp2 = list(map(dir_rp.append, ('1', '2'))) self.assertTrue(rp1.isreg()) self.assertTrue(rp2.isreg()) return (rp1.getuidgid(), rp2.getuidgid()) in_rp = write_ownership_dir() out_rp = rpath.RPath(Globals.local_connection, abs_output_dir) if out_rp.lstat(): Myrm(out_rp.path) self.assertEqual(get_ownership(in_rp), ((0, 0), (userid, 1))) rdiff_backup(1, 0, in_rp.path, out_rp.path, extra_options=(b"--preserve-numerical-ids")) self.assertEqual(get_ownership(out_rp), ((0, 0), (userid, 1)))
def test_final_local(self): """Test backing up and restoring using 'rdiff-backup' script""" self.make_backup_dirs() self.make_temp_out_dirs() rdiff_backup(1, 1, self.ea_test1_rpath.path, tempdir.path, current_time=10000) assert CompareRecursive(self.ea_test1_rpath, tempdir, compare_eas=1) rdiff_backup(1, 1, self.ea_test2_rpath.path, tempdir.path, current_time=20000) assert CompareRecursive(self.ea_test2_rpath, tempdir, compare_eas=1) rdiff_backup(1, 1, tempdir.path, restore_dir.path, extra_options=b'-r 10000') assert CompareRecursive(self.ea_test1_rpath, restore_dir, compare_eas=1)
def generic_selective_test(self, local, compare_option): """Used for selective tests--just compare part of a backup""" rdiff_backup(local, local, os.path.join(old_inc3_dir, b'various_file_types'), os.path.join(abs_output_dir, b'various_file_types'), extra_options=compare_option) self.assertTrue( rdiff_backup(local, local, os.path.join(old_inc2_dir, b'increment1'), os.path.join(abs_output_dir, b'increment1'), extra_options=compare_option, check_return_val=0)) rdiff_backup(local, local, os.path.join(old_inc2_dir, b'newdir'), os.path.join(abs_output_dir, b'newdir'), extra_options=compare_option + b"-at-time 10000") self.assertTrue( rdiff_backup(local, local, os.path.join(old_inc3_dir, b'newdir'), os.path.join(abs_output_dir, b'newdir'), extra_options=compare_option + b"-at-time 10000", check_return_val=0))
def testLegacy(self): """Test restoring directory with no mirror_metadata file""" self.delete_tmpdirs() rdiff_backup(True, True, Local.vftrp.path, Local.rpout.path, current_time=10000) rdiff_backup(True, True, Local.emptyrp.path, Local.rpout.path, current_time=20000) # remove mirror_metadata files to simulate old style backups # pathlib.Path doesn't work with bytes hence need to work with str path for mirror_file in pathlib.Path( os.fsdecode(Local.rpout.append( b'rdiff-backup-data').path)).glob('mirror_metadata*'): mirror_file.unlink() rdiff_backup(True, True, Local.rpout.path, Local.rpout1.path, extra_options=b'-r0') assert CompareRecursive(Local.vftrp, Local.rpout1, compare_hardlinks=0)
def generic_test(self, local, compare_option): """Used for 6 tests below""" rdiff_backup(local, local, old_inc3_dir, self.outdir, extra_options=compare_option) self.assertTrue( rdiff_backup(local, local, old_inc2_dir, self.outdir, extra_options=compare_option, check_return_val=0)) rdiff_backup(local, local, old_inc2_dir, self.outdir, extra_options=compare_option + b"-at-time 10000") self.assertTrue( rdiff_backup(local, local, old_inc3_dir, self.outdir, extra_options=compare_option + b"-at-time 10000", check_return_val=0))
def testSelFilesRemote(self): """Test for bug found in 0.7.[34] - filelist where source remote""" self.delete_tmpdirs() Local.vft_out.mkdir() # Make an exclude list excluderp = Local.vft_out.append("exclude") with excluderp.open("wb") as fp: fp.write(Local.vftrp.append('regular_file').path) fp.write(Local.vftrp.append('test').path) # Make an include list includerp = Local.vft_out.append("include") with includerp.open("wb") as fp: fp.write(Local.vftrp.append('executable').path) fp.write(Local.vftrp.append('symbolic_link').path) fp.write(Local.vftrp.append('regular_file').path) fp.write(Local.vftrp.append('test').path) rdiff_backup( False, False, Local.vftrp.path, Local.rpout.path, extra_options=b"--exclude-filelist %b --include-filelist %b" b" --exclude '**'" % (excluderp.path, includerp.path)) rdiff_backup(False, False, Local.rpout.path, Local.rpout1.path, extra_options=b"--restore-as-of now") assert os.lstat(Local.rpout1.append('executable').path) # FIXME: should symbolic links to excluded files be included? # assert os.lstat(Local.rpout1.append('symbolic_link').path) self.assertRaises(OSError, os.lstat, Local.rpout1.append('regular_file').path) self.assertRaises(OSError, os.lstat, Local.rpout1.append('executable2').path)
def testSelLocal(self): """Quick backup testing a few selection options""" self.delete_tmpdirs() # create a few relative paths to check a different approach than absolute inc2_rel = os.path.relpath(Local.inc2rp.path) out_rel = os.path.relpath(Local.rpout.path) rest1_rel = os.path.relpath(Local.rpout1.path) # Test --include option rdiff_backup( True, True, inc2_rel, out_rel, extra_options=b"--current-time 10000 --include %b --exclude '**' " % os.path.join(inc2_rel, b"various_file_types")) # check that one included file exists and one excluded doesn't assert os.lstat( os.path.join(out_rel, b"various_file_types", b"regular_file")) self.assertRaises(OSError, os.lstat, os.path.join(out_rel, b"test.py")) # Now try reading list of files rdiff_backup(True, True, inc2_rel, out_rel, extra_options=b"--current-time 20000 --include-filelist-stdin --exclude '**' ", input=b"\n%b\n%b" % (os.path.join(inc2_rel, b"test.py"), os.path.join(inc2_rel, b"changed_dir"))) # check that two included files exist and two excluded don't assert os.lstat(os.path.join(out_rel, b"changed_dir")) assert os.lstat(os.path.join(out_rel, b"test.py")) self.assertRaises(OSError, os.lstat, os.path.join(out_rel, b"various_file_types")) self.assertRaises(OSError, os.lstat, os.path.join(out_rel, b"changed_dir", b"foo")) # Test selective restoring mirror_rp = rpath.RPath(Globals.local_connection, out_rel) restore_filename = get_increment_rp(mirror_rp, 10000).path rdiff_backup( True, True, restore_filename, rest1_rel, extra_options=b"--include-filelist-stdin " + b" --exclude '**'", input=b"\n%b" % os.path.join(rest1_rel, b"various_file_types", b"regular_file")) assert os.lstat( os.path.join(rest1_rel, b"various_file_types", b"regular_file")) self.assertRaises(OSError, os.lstat, os.path.join(rest1_rel, b"tester")) self.assertRaises( OSError, os.lstat, os.path.join(rest1_rel, b"various_file_types", b"executable"))
def test_dest_delete(self): """Test deleting a directory from the destination dir Obviously that directory can no longer be restored, but the rest of the files should be OK. Just runs locally for now. """ in_dir1, in_subdir, in_dir2 = self.make_dir() rdiff_backup(True, True, in_dir1.path, Local.rpout.path, current_time=10000) out_subdir = Local.rpout.append(in_subdir.index[-1]) log.Log("Deleting %s" % out_subdir.get_safepath(), 3) out_subdir.delete() rdiff_backup(True, True, Local.rpout.path, Local.rpout1.path, extra_options=b"--restore-as-of 10000")
def testEmptyDirInclude(self): """Make sure empty directories are included with **xx exps This checks for a bug present in 1.0.3/1.1.5 and similar. """ outrp = MakeOutputDir() # we need to change directory to be able to work with relative paths os.chdir(abs_test_dir) os.chdir(os.pardir) # chdir one level up selrp = rpath.RPath(Globals.local_connection, 'testfiles/seltest') re_init_rpath_dir(selrp) emptydir = selrp.append('emptydir') emptydir.mkdir() rdiff_backup(1, 1, selrp.path, outrp.path, extra_options=(b"--include **XX " b"--exclude testfiles/seltest/YYYY")) outempty = outrp.append('emptydir') assert outempty.isdir(), outempty
def testProcLocalToRemote(self): """Test mirroring proc remote""" procout_dir = os.path.join(abs_test_dir, b"procoutput") Myrm(procout_dir) procout = rpath.RPath(Globals.local_connection, procout_dir) rdiff_backup(True, False, '/proc', procout.path, current_time=10000) time.sleep(1) rdiff_backup(True, False, '/proc', procout.path, current_time=20000) time.sleep(1) rdiff_backup(True, False, Local.inc1rp.path, procout.path, current_time=30000) assert CompareRecursive(Local.inc1rp, procout) time.sleep(1) rdiff_backup(True, False, '/proc', procout.path, current_time=40000)
def testProcLocal(self): """Test initial backup of /proc locally""" procout_dir = os.path.join(abs_test_dir, b"procoutput") Myrm(procout_dir) procout = rpath.RPath(Globals.local_connection, procout_dir) rdiff_backup(True, True, '/proc', procout.path, current_time=10000) time.sleep(1) rdiff_backup(True, True, '/proc', procout.path, current_time=20000) time.sleep(1) rdiff_backup(True, True, Local.inc1rp.path, procout.path, current_time=30000) self.assertTrue(compare_recursive(Local.inc1rp, procout)) time.sleep(1) rdiff_backup(True, True, '/proc', procout.path, current_time=40000)
def test_symlink_popple(self): """Test for Popple's symlink bug Earlier, certain symlinks could cause data loss in _source_ directory when regressing. See mailing lists around 4/2/05 for more info. """ self.delete_tmpdirs() # Make directories rp1 = Local.get_tgt_local_rp('sym_in1') if rp1.lstat(): rp1.delete() rp1.mkdir() rp1_d = rp1.append('subdir') rp1_d.mkdir() rp1_d_f = rp1_d.append('file') rp1_d_f.touch() rp2 = Local.get_tgt_local_rp('sym_in2') if rp2.lstat(): rp2.delete() rp2.mkdir() rp2_s = rp2.append('subdir') rp2_s.symlink("%s/%s" % (abs_test_dir, rp1_d.path)) # Backup rdiff_backup(True, True, rp1.path, Local.rpout.path, current_time=10000) rdiff_backup(True, True, rp2.path, Local.rpout.path, current_time=20000) # Make failed backup rbdir = Local.rpout.append('rdiff-backup-data') curmir = rbdir.append('current_mirror.%s.data' % (Time.timetostring(30000), )) curmir.touch() # Regress rdiff_backup(True, True, Local.rpout.path, None, current_time=30000, extra_options=b'--check-destination-dir') # Check to see if file still there rp1_d_f.setdata() assert rp1_d_f.isreg(), 'File %a corrupted' % (rp1_d_f.path, )
def generic_test(self, inlocal, outlocal, extra_args, compare_back): """Used for some of the tests below""" in1, in2 = self.make_input_dirs() Myrm(self.out_rp.path) restore_dir = self.root_rp.append('longname_out') # Test backing up rdiff_backup(inlocal, outlocal, in1.path, self.out_rp.path, 10000, extra_options=extra_args) if compare_back: self.check_dir1(self.out_rp) rdiff_backup(inlocal, outlocal, in2.path, self.out_rp.path, 20000, extra_options=extra_args) if compare_back: self.check_dir2(self.out_rp) # Now try restoring Myrm(restore_dir.path) rdiff_backup(inlocal, outlocal, self.out_rp.path, restore_dir.path, 30000, extra_options=b"-r now " + extra_args) self.check_dir2(restore_dir) Myrm(restore_dir.path) rdiff_backup(1, 1, self.out_rp.path, restore_dir.path, 30000, extra_options=b"-r 10000 " + extra_args) self.check_dir1(restore_dir)
def test_final_local(self): """Test backing up and restoring using 'rdiff-backup' script""" self.make_backup_dirs() self.make_temp_out_dirs() rdiff_backup(1, 1, self.acl_test1_rpath.path, tempdir.path, current_time=10000) self.assertTrue( compare_recursive(self.acl_test1_rpath, tempdir, compare_acls=1)) rdiff_backup(1, 1, self.acl_test2_rpath.path, tempdir.path, current_time=20000) self.assertTrue( compare_recursive(self.acl_test2_rpath, tempdir, compare_acls=1)) rdiff_backup(1, 1, tempdir.path, restore_dir.path, extra_options=b'-r 10000') self.assertTrue( compare_recursive(self.acl_test1_rpath, restore_dir, compare_acls=1)) restore_dir.delete() rdiff_backup(1, 1, tempdir.path, restore_dir.path, extra_options=b'-r now') self.assertTrue( compare_recursive(self.acl_test2_rpath, restore_dir, compare_acls=1))
def testRemoveOlderThanQuoting(self): """Test --remove-older-than when dest directory is quoted""" Myrm(Local.rpout.path) rdiff_backup(True, True, Local.inc1rp.path, Local.rpout.path, extra_options=b"--override-chars-to-quote '^a-z0-9_ -.'" b" --current-time 10000") rdiff_backup(True, True, Local.inc2rp.path, Local.rpout.path, extra_options=b"--override-chars-to-quote '^a-z0-9_ -.'" b" --current-time 20000") rdiff_backup(True, True, Local.rpout.path, None, extra_options=b"--remove-older-than now")
def runtest(self, from_local, to_local): self.delete_tmpdirs() # Backing up increment1 rdiff_backup(from_local, to_local, Local.inc1rp.path, Local.rpout.path, current_time=10000) assert CompareRecursive(Local.inc1rp, Local.rpout) time.sleep(1) # Backing up increment2 rdiff_backup(from_local, to_local, Local.inc2rp.path, Local.rpout.path, current_time=20000) assert CompareRecursive(Local.inc2rp, Local.rpout) time.sleep(1) # Backing up increment3 rdiff_backup(from_local, to_local, Local.inc3rp.path, Local.rpout.path, current_time=30000) assert CompareRecursive(Local.inc3rp, Local.rpout) time.sleep(1) # Backing up increment4 rdiff_backup(from_local, to_local, Local.inc4rp.path, Local.rpout.path, current_time=40000) assert CompareRecursive(Local.inc4rp, Local.rpout) # Getting restore rps inc_paths = self.getinc_paths( b"increments.", os.path.join(Local.rpout.path, b"rdiff-backup-data")) assert len(inc_paths) == 3 # Restoring increment1 rdiff_backup(from_local, to_local, inc_paths[0], Local.rpout1.path) assert CompareRecursive(Local.inc1rp, Local.rpout1) # Restoring increment2 rdiff_backup(from_local, to_local, inc_paths[1], Local.rpout2.path) assert CompareRecursive(Local.inc2rp, Local.rpout2) # Restoring increment3 rdiff_backup(from_local, to_local, inc_paths[2], Local.rpout3.path) assert CompareRecursive(Local.inc3rp, Local.rpout3) # Test restoration of a few random files vft_paths = self.getinc_paths( b"various_file_types.", os.path.join(Local.rpout.path, b"rdiff-backup-data", b"increments")) rdiff_backup(from_local, to_local, vft_paths[1], Local.vft_out.path) self.refresh(Local.vft_in, Local.vft_out) assert CompareRecursive(Local.vft_in, Local.vft_out) timbar_paths = self.getinc_paths( b"timbar.pyc.", os.path.join(Local.rpout.path, b"rdiff-backup-data", b"increments")) rdiff_backup(from_local, to_local, timbar_paths[0], Local.timbar_out.path) self.refresh(Local.timbar_in, Local.timbar_out) assert Local.timbar_in.equal_loose(Local.timbar_out) rdiff_backup(from_local, to_local, Local.rpout.append('various_file_types').path, Local.vft_recover.path, extra_options=b"--restore-as-of 25000") self.refresh(Local.vft_recover, Local.vft_in) assert CompareRecursive(Local.vft_recover, Local.vft_in) # Make sure too many increment files not created assert len( self.getinc_paths( b"nochange.", os.path.join(Local.rpout.path, b"rdiff-backup-data", b"increments"))) == 0 nochange_incs = len( self.getinc_paths( b"", os.path.join(Local.rpout.path, b"rdiff-backup-data", b"increments", b"nochange"))) assert nochange_incs == 1 or nochange_incs == 0, nochange_incs
def testDuplicateMetadataTimestamp(self): """This test is based on issue #322 where a diff and a snapshot metadata mirror files had the same timestamp, which made rdiff-backup choke. We check that rdiff-backup still fails by default but can be taught to ignore the error with --allow-duplicate-timestamps so that the repo can be fixed.""" # create an empty directory test_base_rp = self.makerp(abs_test_dir).append("dupl_meta_time") re_init_rpath_dir(test_base_rp) # create enough incremental backups to have one metadata snapshot # in-between, which we can manipulate to simulate the error source_rp = test_base_rp.append("source") target_rp = test_base_rp.append("target") source_rp.mkdir() for suffix in range(1, 15): source_rp.append("file%02d" % suffix).touch() rdiff_backup(1, 1, source_rp.__fspath__(), target_rp.__fspath__(), current_time=suffix * 10000) # identify the oldest (aka first) mirror metadata snapshot # and sort the list because some filesystems don't respect the order rb_data_rp = target_rp.append("rdiff-backup-data") files_list = sorted(filter( lambda x: x.startswith(b"mirror_metadata."), rb_data_rp.listdir())) meta_snapshot_rp = rb_data_rp.append(files_list[8]) # create a diff with the same data as the identified snapshot meta_dupldiff_rp = rb_data_rp.append(files_list[8].replace( b".snapshot.gz", b".diff.gz")) rpath.copy(meta_snapshot_rp, meta_dupldiff_rp) # this succeeds rdiff_backup(1, 1, target_rp.__fspath__(), None, extra_options=b"--check-destination-dir") # now this should fail source_rp.append("file15").touch() rdiff_backup(1, 1, source_rp.__fspath__(), target_rp.__fspath__(), current_time=15 * 10000, expected_ret_val=1) # and this should also fail rdiff_backup(1, 1, target_rp.__fspath__(), None, expected_ret_val=1, extra_options=b"--check-destination-dir") # but this should succeed rdiff_backup(1, 1, target_rp.__fspath__(), None, extra_options=b"--allow-duplicate-timestamps --check-destination-dir") # now we can clean-up, getting rid of the duplicate metadata mirrors # NOTE: we could have cleaned-up even without checking/fixing the directory # but this shouldn't be the recommended practice. rdiff_backup(1, 1, target_rp.__fspath__(), None, extra_options=b"--remove-older-than 100000 --force") # and this should at last succeed source_rp.append("file16").touch() rdiff_backup(1, 1, source_rp.__fspath__(), target_rp.__fspath__(), current_time=16 * 10000)
def test_delete_with_deleted_directory(self): self._copy_repo(b'restoretest3') rdiff_backup_delete(to_delete=os.path.join(self.repo, b'increment1')) rdiff_backup(1, 1, self.repo, None, extra_options=b"--verify") self.assertNotFound(b'increment1')
def test_delete_with_file(self): self._copy_repo(b'restoretest4') rdiff_backup_delete(to_delete=os.path.join(self.repo, b'tmp/changed')) rdiff_backup(1, 1, self.repo, None, extra_options=b"--verify") self.assertNotFound(b'changed')
def testProcRemoteToLocal(self): """Test mirroring proc, this time when proc is remote, dest local""" procout_dir = os.path.join(abs_test_dir, b"procoutput") Myrm(procout_dir) procout = rpath.RPath(Globals.local_connection, procout_dir) rdiff_backup(False, True, '/proc', procout.path)
def test_delete_with_dryrun(self): self._copy_repo(b'restoretest4') rdiff_backup_delete(to_delete=os.path.join(self.repo, b'tmp'), extra_args=[b'--dry-run']) rdiff_backup(1, 1, self.repo, None, extra_options=b"--verify") self.assertFound(b'tmp')