Fix "borgmatic borg key ..." to pass parameters to Borg in correct order (#515).
This commit is contained in:
parent
bdc26f2117
commit
0e6b425ac5
3 changed files with 18 additions and 4 deletions
1
NEWS
1
NEWS
|
@ -6,6 +6,7 @@
|
||||||
once for each configured repository instead of once per configuration file. Additionally, the
|
once for each configured repository instead of once per configuration file. Additionally, the
|
||||||
"repositories" interpolated variable has been changed to "repository", containing the path to the
|
"repositories" interpolated variable has been changed to "repository", containing the path to the
|
||||||
current repository for the hook.
|
current repository for the hook.
|
||||||
|
* #515: Fix "borgmatic borg key ..." to pass parameters to Borg in correct order.
|
||||||
* #516: Fix handling of TERM signal to exit borgmatic, not just forward the signal to Borg.
|
* #516: Fix handling of TERM signal to exit borgmatic, not just forward the signal to Borg.
|
||||||
* #517: Fix borgmatic exit code (so it's zero) when initial Borg calls fail but later retries
|
* #517: Fix borgmatic exit code (so it's zero) when initial Borg calls fail but later retries
|
||||||
succeed.
|
succeed.
|
||||||
|
|
|
@ -21,17 +21,20 @@ def run_arbitrary_borg(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
options = options[1:] if options[0] == '--' else options
|
options = options[1:] if options[0] == '--' else options
|
||||||
borg_command = options[0]
|
|
||||||
command_options = tuple(options[1:])
|
# Borg's "key" command has a sub-command ("export", etc.) that must follow it.
|
||||||
|
command_options_start_index = 2 if options[0] == 'key' else 1
|
||||||
|
borg_command = tuple(options[:command_options_start_index])
|
||||||
|
command_options = tuple(options[command_options_start_index:])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
borg_command = None
|
borg_command = ()
|
||||||
command_options = ()
|
command_options = ()
|
||||||
|
|
||||||
repository_archive = '::'.join((repository, archive)) if repository and archive else repository
|
repository_archive = '::'.join((repository, archive)) if repository and archive else repository
|
||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path,)
|
(local_path,)
|
||||||
+ ((borg_command,) if borg_command else ())
|
+ borg_command
|
||||||
+ ((repository_archive,) if borg_command and repository_archive else ())
|
+ ((repository_archive,) if borg_command and repository_archive else ())
|
||||||
+ command_options
|
+ command_options
|
||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
|
|
|
@ -121,3 +121,13 @@ def test_run_arbitrary_borg_without_borg_specific_parameters_does_not_raise():
|
||||||
module.run_arbitrary_borg(
|
module.run_arbitrary_borg(
|
||||||
repository='repo', storage_config={}, options=[],
|
repository='repo', storage_config={}, options=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_arbitrary_borg_passes_key_sub_command_to_borg_before_repository():
|
||||||
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
|
('borg', 'key', 'export', 'repo'), output_log_level=logging.WARNING, borg_local_path='borg',
|
||||||
|
)
|
||||||
|
|
||||||
|
module.run_arbitrary_borg(
|
||||||
|
repository='repo', storage_config={}, options=['key', 'export'],
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue