From d664b6d253bdf82f297464a071b4d0cadd9821d8 Mon Sep 17 00:00:00 2001 From: Thomas LEVEIL Date: Sun, 1 Jul 2018 21:09:45 +0200 Subject: [PATCH] only run hooks when creating an archive fix #72 --- borgmatic/commands/borgmatic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index a5e4b7a63..99d5471bc 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -115,7 +115,9 @@ def run_configuration(config_filename, args): # pragma: no cover local_path = location.get('local_path', 'borg') remote_path = location.get('remote_path') borg_create.initialize_environment(storage) - hook.execute_hook(hooks.get('before_backup'), config_filename, 'pre-backup') + + if args.create: + hook.execute_hook(hooks.get('before_backup'), config_filename, 'pre-backup') for unexpanded_repository in location['repositories']: repository = os.path.expanduser(unexpanded_repository) @@ -171,7 +173,8 @@ def run_configuration(config_filename, args): # pragma: no cover remote_path=remote_path, ) - hook.execute_hook(hooks.get('after_backup'), config_filename, 'post-backup') + if args.create: + hook.execute_hook(hooks.get('after_backup'), config_filename, 'post-backup') except (OSError, CalledProcessError): hook.execute_hook(hooks.get('on_error'), config_filename, 'on-error') raise