diff --git a/backupbot.py b/backupbot.py index afa0c17..78c0778 100755 --- a/backupbot.py +++ b/backupbot.py @@ -112,7 +112,8 @@ def create(retries): @click.option('noninteractive', '--noninteractive', envvar='NONINTERACTIVE', is_flag=True) @click.option('volumes', '--volumes', '-v', envvar='VOLUMES', multiple=True) @click.option('container', '--container', '-c', envvar='CONTAINER', multiple=True) -def restore(snapshot, target, noninteractive, volumes, container): +@click.option('no_commands', '--no-commands', envvar='NO_COMMANDS', is_flag=True) +def restore(snapshot, target, noninteractive, volumes, container, no_commands): app_settings = parse_backup_labels('restore', container) if SERVICE != 'ALL': app_settings = {SERVICE: app_settings[SERVICE]} @@ -136,9 +137,13 @@ def restore(snapshot, target, noninteractive, volumes, container): logger.error("Restore aborted") exit(1) print(f"Restoring Snapshot {snapshot} at {target}") - run_commands(pre_commands) + if not no_commands and pre_commands: + print(f"Run pre commands.") + run_commands(pre_commands) result = restic_restore(snapshot_id=snapshot, include=backup_paths, target_dir=target) - run_commands(post_commands) + if not no_commands and post_commands: + print(f"Run post commands.") + run_commands(post_commands) logger.debug(result)