def restore(self, backup, restore_path): """ :type backup: freezer.storage.Backup """ logging.info("Creation restore path: {0}".format(restore_path)) utils.create_dir_tree(restore_path) logging.info("Creation restore path completed") for level in range(0, backup.level + 1): b = backup.full_backup.increments[level] logging.info("Restore backup {0}".format(b)) read_pipe, write_pipe = multiprocessing.Pipe() process_stream = multiprocessing.Process( target=self.read_blocks, args=(b, write_pipe, read_pipe)) process_stream.daemon = True process_stream.start() write_pipe.close() # Start the tar pipe consumer process tar_stream = multiprocessing.Process( target=self.restore_level, args=(restore_path, read_pipe)) tar_stream.daemon = True tar_stream.start() read_pipe.close() write_pipe.close() process_stream.join() tar_stream.join() if tar_stream.exitcode: raise Exception('failed to restore file') logging.info( '[*] Restore execution successfully executed \ for backup name {0}'.format(backup))
def find_all(self, hostname_backup_name): backups = [] backup_dir = utils.path_join(self.storage_directory, hostname_backup_name) utils.create_dir_tree(backup_dir) timestamps = self.listdir(backup_dir) for timestamp in timestamps: increments = \ self.listdir(utils.path_join(backup_dir, timestamp)) backups.extend(base.Backup.parse_backups(increments, self)) return backups
def restore(self, backup, restore_path): """ :type backup: freezer.storage.Backup """ logging.info("Creation restore path: {0}".format(restore_path)) utils.create_dir_tree(restore_path) logging.info("Creation restore path completed") for level in range(0, backup.level + 1): b = backup.full_backup.increments[level] logging.info("Restore backup {0}".format(b)) streaming.stream( self.main_storage.read_backup, {"backup": b}, self.restore_stream, {"restore_path": restore_path}) logging.info( '[*] Restore execution successfully executed \ for backup name {0}'.format(backup))
def create_dirs(self, path): utils.create_dir_tree(path)