Fix "borg create" flags/argument interleaving.
This commit is contained in:
parent
193dd93de2
commit
5d80c366fb
2 changed files with 31 additions and 34 deletions
|
@ -420,7 +420,7 @@ def create_archive(
|
||||||
f'{repository_path}: Ignoring configured "read_special" value of false, as true is needed for database hooks.'
|
f'{repository_path}: Ignoring configured "read_special" value of false, as true is needed for database hooks.'
|
||||||
)
|
)
|
||||||
|
|
||||||
create_command = (
|
create_flags = (
|
||||||
tuple(local_path.split(' '))
|
tuple(local_path.split(' '))
|
||||||
+ ('create',)
|
+ ('create',)
|
||||||
+ make_pattern_flags(config, pattern_file.name if pattern_file else None)
|
+ make_pattern_flags(config, pattern_file.name if pattern_file else None)
|
||||||
|
@ -449,11 +449,11 @@ def create_archive(
|
||||||
)
|
)
|
||||||
+ (('--dry-run',) if dry_run else ())
|
+ (('--dry-run',) if dry_run else ())
|
||||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||||
+ flags.make_repository_archive_flags(
|
)
|
||||||
|
|
||||||
|
create_positional_arguments = flags.make_repository_archive_flags(
|
||||||
repository_path, archive_name_format, local_borg_version
|
repository_path, archive_name_format, local_borg_version
|
||||||
)
|
) + (sources if not pattern_file else ())
|
||||||
+ (sources if not pattern_file else ())
|
|
||||||
)
|
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
output_log_level = None
|
output_log_level = None
|
||||||
|
@ -473,7 +473,7 @@ def create_archive(
|
||||||
if stream_processes and not config.get('read_special'):
|
if stream_processes and not config.get('read_special'):
|
||||||
logger.debug(f'{repository_path}: Collecting special file paths')
|
logger.debug(f'{repository_path}: Collecting special file paths')
|
||||||
special_file_paths = collect_special_file_paths(
|
special_file_paths = collect_special_file_paths(
|
||||||
create_command,
|
create_flags + create_positional_arguments,
|
||||||
local_path,
|
local_path,
|
||||||
working_directory,
|
working_directory,
|
||||||
borg_environment,
|
borg_environment,
|
||||||
|
@ -490,9 +490,9 @@ def create_archive(
|
||||||
),
|
),
|
||||||
pattern_file=exclude_file,
|
pattern_file=exclude_file,
|
||||||
)
|
)
|
||||||
create_command += make_exclude_flags(config, exclude_file.name)
|
create_flags += make_exclude_flags(config, exclude_file.name)
|
||||||
|
|
||||||
create_command += (
|
create_flags += (
|
||||||
(('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ())
|
(('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ())
|
||||||
+ (('--stats',) if stats and not json and not dry_run else ())
|
+ (('--stats',) if stats and not json and not dry_run else ())
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ())
|
||||||
|
@ -502,7 +502,7 @@ def create_archive(
|
||||||
|
|
||||||
if stream_processes:
|
if stream_processes:
|
||||||
return execute_command_with_processes(
|
return execute_command_with_processes(
|
||||||
create_command,
|
create_flags + create_positional_arguments,
|
||||||
stream_processes,
|
stream_processes,
|
||||||
output_log_level,
|
output_log_level,
|
||||||
output_file,
|
output_file,
|
||||||
|
@ -512,14 +512,14 @@ def create_archive(
|
||||||
)
|
)
|
||||||
elif output_log_level is None:
|
elif output_log_level is None:
|
||||||
return execute_command_and_capture_output(
|
return execute_command_and_capture_output(
|
||||||
create_command,
|
create_flags + create_positional_arguments,
|
||||||
working_directory=working_directory,
|
working_directory=working_directory,
|
||||||
extra_environment=borg_environment,
|
extra_environment=borg_environment,
|
||||||
borg_local_path=local_path,
|
borg_local_path=local_path,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
execute_command(
|
execute_command(
|
||||||
create_command,
|
create_flags + create_positional_arguments,
|
||||||
output_log_level,
|
output_log_level,
|
||||||
output_file,
|
output_file,
|
||||||
borg_local_path=local_path,
|
borg_local_path=local_path,
|
||||||
|
|
|
@ -760,7 +760,7 @@ def test_create_archive_with_log_info_calls_borg_with_info_parameter():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--info',),
|
('borg', 'create', '--info') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -803,7 +803,7 @@ def test_create_archive_with_log_info_and_json_suppresses_most_borg_output():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--json',),
|
('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
working_directory=None,
|
working_directory=None,
|
||||||
extra_environment=None,
|
extra_environment=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -845,7 +845,7 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_parameter():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--debug', '--show-rc'),
|
('borg', 'create', '--debug', '--show-rc') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -888,7 +888,7 @@ def test_create_archive_with_log_debug_and_json_suppresses_most_borg_output():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--json',),
|
('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
working_directory=None,
|
working_directory=None,
|
||||||
extra_environment=None,
|
extra_environment=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -974,7 +974,7 @@ def test_create_archive_with_stats_and_dry_run_calls_borg_without_stats_paramete
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create', '--dry-run') + REPO_ARCHIVE_WITH_PATHS + ('--info',),
|
('borg', 'create', '--dry-run', '--info') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -1849,7 +1849,7 @@ def test_create_archive_with_stats_calls_borg_with_stats_parameter_and_answer_ou
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--stats',),
|
('borg', 'create', '--stats') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
output_log_level=module.borgmatic.logger.ANSWER,
|
output_log_level=module.borgmatic.logger.ANSWER,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -1935,12 +1935,7 @@ def test_create_archive_with_progress_and_log_info_calls_borg_with_progress_para
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create')
|
('borg', 'create', '--info', '--progress') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
+ REPO_ARCHIVE_WITH_PATHS
|
|
||||||
+ (
|
|
||||||
'--info',
|
|
||||||
'--progress',
|
|
||||||
),
|
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=module.DO_NOT_CAPTURE,
|
output_file=module.DO_NOT_CAPTURE,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -1984,7 +1979,7 @@ def test_create_archive_with_progress_calls_borg_with_progress_parameter():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--progress',),
|
('borg', 'create', '--progress') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=module.DO_NOT_CAPTURE,
|
output_file=module.DO_NOT_CAPTURE,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -2029,10 +2024,12 @@ def test_create_archive_with_progress_and_stream_processes_calls_borg_with_progr
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('collect_special_file_paths').and_return(())
|
flexmock(module).should_receive('collect_special_file_paths').and_return(())
|
||||||
create_command = (
|
create_command = (
|
||||||
('borg', 'create', '--one-file-system', '--read-special')
|
'borg',
|
||||||
+ REPO_ARCHIVE_WITH_PATHS
|
'create',
|
||||||
+ ('--progress',)
|
'--one-file-system',
|
||||||
)
|
'--read-special',
|
||||||
|
'--progress',
|
||||||
|
) + REPO_ARCHIVE_WITH_PATHS
|
||||||
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
||||||
create_command + ('--dry-run', '--list'),
|
create_command + ('--dry-run', '--list'),
|
||||||
processes=processes,
|
processes=processes,
|
||||||
|
@ -2158,14 +2155,14 @@ def test_create_archive_with_stream_processes_adds_special_files_to_excludes():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('collect_special_file_paths').and_return(('special',))
|
flexmock(module).should_receive('collect_special_file_paths').and_return(('special',))
|
||||||
create_command = (
|
create_flags = (
|
||||||
'borg',
|
'borg',
|
||||||
'create',
|
'create',
|
||||||
'--one-file-system',
|
'--one-file-system',
|
||||||
'--read-special',
|
'--read-special',
|
||||||
) + REPO_ARCHIVE_WITH_PATHS
|
)
|
||||||
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
||||||
create_command + ('--dry-run', '--list'),
|
create_flags + ('--dry-run', '--list') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
processes=processes,
|
processes=processes,
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
|
@ -2174,7 +2171,7 @@ def test_create_archive_with_stream_processes_adds_special_files_to_excludes():
|
||||||
extra_environment=None,
|
extra_environment=None,
|
||||||
)
|
)
|
||||||
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
||||||
create_command + ('--exclude-from', '/excludes'),
|
create_flags + ('--exclude-from', '/excludes') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
processes=processes,
|
processes=processes,
|
||||||
output_log_level=logging.INFO,
|
output_log_level=logging.INFO,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
|
@ -2282,7 +2279,7 @@ def test_create_archive_with_json_calls_borg_with_json_parameter():
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--json',),
|
('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
working_directory=None,
|
working_directory=None,
|
||||||
extra_environment=None,
|
extra_environment=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
@ -2325,7 +2322,7 @@ def test_create_archive_with_stats_and_json_calls_borg_without_stats_parameter()
|
||||||
)
|
)
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
flexmock(module.environment).should_receive('make_environment')
|
||||||
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
||||||
('borg', 'create') + REPO_ARCHIVE_WITH_PATHS + ('--json',),
|
('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
||||||
working_directory=None,
|
working_directory=None,
|
||||||
extra_environment=None,
|
extra_environment=None,
|
||||||
borg_local_path='borg',
|
borg_local_path='borg',
|
||||||
|
|
Loading…
Reference in a new issue