Add before_extract and after_extract hooks (#347).
Reviewed-on: https://projects.torsion.org/witten/borgmatic/pulls/347
This commit is contained in:
commit
93caeba200
3 changed files with 43 additions and 0 deletions
|
@ -91,6 +91,14 @@ def run_configuration(config_filename, config, arguments):
|
|||
'pre-check',
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
if 'extract' in arguments:
|
||||
command.execute_hook(
|
||||
hooks.get('before_extract'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-extract',
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
if prune_create_or_check:
|
||||
dispatch.call_hooks(
|
||||
'ping_monitor',
|
||||
|
@ -165,6 +173,14 @@ def run_configuration(config_filename, config, arguments):
|
|||
'post-check',
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
if 'extract' in arguments:
|
||||
command.execute_hook(
|
||||
hooks.get('after_extract'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'post-extract',
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
if prune_create_or_check:
|
||||
dispatch.call_hooks(
|
||||
'ping_monitor',
|
||||
|
|
|
@ -473,6 +473,14 @@ map:
|
|||
before consistency checks, run once per configuration file.
|
||||
example:
|
||||
- echo "Starting checks."
|
||||
before_extract:
|
||||
seq:
|
||||
- type: str
|
||||
desc: |
|
||||
List of one or more shell commands or scripts to execute
|
||||
before extracting a backup, run once per configuration file.
|
||||
example:
|
||||
- echo "Starting extracting."
|
||||
after_backup:
|
||||
seq:
|
||||
- type: str
|
||||
|
@ -497,6 +505,14 @@ map:
|
|||
after consistency checks, run once per configuration file.
|
||||
example:
|
||||
- echo "Finished checks."
|
||||
after_extract:
|
||||
seq:
|
||||
- type: str
|
||||
desc: |
|
||||
List of one or more shell commands or scripts to execute
|
||||
after extracting a backup, run once per configuration file.
|
||||
example:
|
||||
- echo "Finished extracting."
|
||||
on_error:
|
||||
seq:
|
||||
- type: str
|
||||
|
|
|
@ -54,6 +54,17 @@ def test_run_configuration_calls_hooks_for_check_action():
|
|||
list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
||||
|
||||
def test_run_configuration_calls_hooks_for_extract_action():
|
||||
flexmock(module.borg_environment).should_receive('initialize')
|
||||
flexmock(module.command).should_receive('execute_hook').twice()
|
||||
flexmock(module.dispatch).should_receive('call_hooks').never()
|
||||
flexmock(module).should_receive('run_actions').and_return([])
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'extract': flexmock()}
|
||||
|
||||
list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
||||
|
||||
def test_run_configuration_does_not_trigger_hooks_for_list_action():
|
||||
flexmock(module.borg_environment).should_receive('initialize')
|
||||
flexmock(module.command).should_receive('execute_hook').never()
|
||||
|
|
Loading…
Reference in a new issue