def test_will_remove_files_not_in_backup_in_redumpster_managed_directories(self, tempdir): # Dangerous this test is, as it actually deletes files from the disk. CopyDirectory._default_rsync_args = self.original_default_rsync_args with change_working_directory_to(tempdir.path): production_directory = 'production' backup_directory = 'backup' os.makedirs(production_directory) source_file = join(production_directory, 'important_file') touch(join(tempdir.path, production_directory, '.redumpster_managed')) dump = CopyDirectory(directory=backup_directory, options=dict( source=production_directory )) dump.dump() touch(source_file) dump.restore() expect(os.path.exists(source_file)).is_false()
def test_ensures_hard_link_path_is_always_absolute(self, tempdir): with change_working_directory_to(tempdir.path): production_directory = 'production' backup_directory = 'backup' os.makedirs(production_directory) source_file = join(production_directory, 'important_file') touch(source_file) dump = CopyDirectory(directory=backup_directory, options=dict( source=production_directory )) source_file = abspath(source_file) backup_file = abspath(join(backup_directory, 'important_file')) expect(exists(backup_file)) == False expect(os.stat(source_file).st_nlink) == 1 dump.dump() expect(exists(backup_file)) == True expect(os.stat(source_file).st_nlink) == 2 expect(os.stat(backup_file).st_nlink) == 2
def test_will_overwrite_existing_data_in_redumpster_managed_directories(self, tempdir): with change_working_directory_to(tempdir.path): production_directory = 'production' backup_directory = 'backup' os.makedirs(production_directory) source_file = join(production_directory, 'important_file') touch(source_file) touch(join(tempdir.path, production_directory, '.redumpster_managed')) dump = CopyDirectory(directory=backup_directory, options=dict( source=production_directory )) dump.dump() os.remove(source_file) # ensure we don't write into the hardlinked file with open(source_file, 'w') as f: f.write('this is going to be overwritten by restore') dump.restore() with open(source_file) as f: expect(f.read()) == ''