Browse Source

only run hooks when creating an archive

fix #72
tags/1.2.1
Thomas LÉVEIL 2 years ago
parent
commit
d664b6d253
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      borgmatic/commands/borgmatic.py

+ 5
- 2
borgmatic/commands/borgmatic.py View File

@@ -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


Loading…
Cancel
Save