only run hooks when creating an archive

fix #72
This commit is contained in:
Thomas LEVEIL 2018-07-01 21:09:45 +02:00
parent f42aa0a6f2
commit d664b6d253

View file

@ -115,6 +115,8 @@ 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)
if args.create:
hook.execute_hook(hooks.get('before_backup'), config_filename, 'pre-backup')
for unexpanded_repository in location['repositories']:
@ -171,6 +173,7 @@ def run_configuration(config_filename, args): # pragma: no cover
remote_path=remote_path,
)
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')