Add before_extract and after_extract hooks
This commit is contained in:
parent
99590cb6b6
commit
893fca2816
3 changed files with 43 additions and 0 deletions
|
@ -91,6 +91,14 @@ def run_configuration(config_filename, config, arguments):
|
||||||
'pre-check',
|
'pre-check',
|
||||||
global_arguments.dry_run,
|
global_arguments.dry_run,
|
||||||
)
|
)
|
||||||
|
if 'extract' in arguments:
|
||||||
|
command.execute_hook(
|
||||||
|
hooks.get('before_extract'),
|
||||||
|
hooks.get('umask'),
|
||||||
|
config_filename,
|
||||||
|
'pre-check',
|
||||||
|
global_arguments.dry_run,
|
||||||
|
)
|
||||||
if prune_create_or_check:
|
if prune_create_or_check:
|
||||||
dispatch.call_hooks(
|
dispatch.call_hooks(
|
||||||
'ping_monitor',
|
'ping_monitor',
|
||||||
|
@ -165,6 +173,14 @@ def run_configuration(config_filename, config, arguments):
|
||||||
'post-check',
|
'post-check',
|
||||||
global_arguments.dry_run,
|
global_arguments.dry_run,
|
||||||
)
|
)
|
||||||
|
if 'extract' in arguments:
|
||||||
|
command.execute_hook(
|
||||||
|
hooks.get('after_extract'),
|
||||||
|
hooks.get('umask'),
|
||||||
|
config_filename,
|
||||||
|
'post-check',
|
||||||
|
global_arguments.dry_run,
|
||||||
|
)
|
||||||
if prune_create_or_check:
|
if prune_create_or_check:
|
||||||
dispatch.call_hooks(
|
dispatch.call_hooks(
|
||||||
'ping_monitor',
|
'ping_monitor',
|
||||||
|
|
|
@ -473,6 +473,14 @@ map:
|
||||||
before consistency checks, run once per configuration file.
|
before consistency checks, run once per configuration file.
|
||||||
example:
|
example:
|
||||||
- echo "Starting checks."
|
- 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:
|
after_backup:
|
||||||
seq:
|
seq:
|
||||||
- type: str
|
- type: str
|
||||||
|
@ -497,6 +505,14 @@ map:
|
||||||
after consistency checks, run once per configuration file.
|
after consistency checks, run once per configuration file.
|
||||||
example:
|
example:
|
||||||
- echo "Finished checks."
|
- 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:
|
on_error:
|
||||||
seq:
|
seq:
|
||||||
- type: str
|
- type: str
|
||||||
|
|
|
@ -54,6 +54,17 @@ def test_run_configuration_calls_hooks_for_check_action():
|
||||||
list(module.run_configuration('test.yaml', config, arguments))
|
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():
|
def test_run_configuration_does_not_trigger_hooks_for_list_action():
|
||||||
flexmock(module.borg_environment).should_receive('initialize')
|
flexmock(module.borg_environment).should_receive('initialize')
|
||||||
flexmock(module.command).should_receive('execute_hook').never()
|
flexmock(module.command).should_receive('execute_hook').never()
|
||||||
|
|
Loading…
Reference in a new issue