def restore(self): ''' perform the restore operation, restoring packages and files recorded ''' if config.options.log_level_at_least('normal'): callback.snapcallback.message("Restoring Snapshot") self.check_permission() # temp directory used to extract tarball construct_dir = tempfile.mkdtemp() FileManager.make_dir(construct_dir) OutputFormatter.retrieve(config.options.outputformat, infile=config.options.snapfile, snapdirectory=construct_dir, encryption_password=config.options.encryption_password) backends = self.load_backends() configured_targets = backends.keys() for target in SnapshotTarget.BACKENDS: # load from SnapShotTarget to preserve order if target in configured_targets: backend = backends[target] backend.restore(construct_dir) if config.options.log_level_at_least('normal'): callback.snapcallback.message("Restore completed") FileManager.rm_dir(construct_dir)
def backup(self): ''' peform the backup operation, recording installed packages and copying new/modified files ''' if config.options.log_level_at_least('normal'): callback.snapcallback.message("Creating snapshot") self.check_permission() # temp directory used to construct tarball construct_dir = tempfile.mkdtemp() FileManager.make_dir(construct_dir) backends = self.load_backends() configured_targets = backends.keys() for target in SnapshotTarget.BACKENDS: # load from SnapshotTarget to preserve order if target in configured_targets: backend = backends[target] includes = config.options.target_includes[target] excludes = config.options.target_excludes[target] backend.backup(construct_dir, include=includes, exclude=excludes) OutputFormatter.create(config.options.outputformat, outfile=config.options.snapfile, snapdirectory=construct_dir, encryption_password=config.options.encryption_password) if config.options.log_level_at_least('normal'): callback.snapcallback.message("Snapshot completed") FileManager.rm_dir(construct_dir)