|
@@ -277,7 +277,7 @@ def test_borgmatic_source_directories_defaults_when_directory_not_given():
|
|
|
|
|
|
|
|
|
DEFAULT_ARCHIVE_NAME = '{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}'
|
|
|
-ARCHIVE_WITH_PATHS = ('repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'bar')
|
|
|
+REPO_ARCHIVE_WITH_PATHS = (f'repo::{DEFAULT_ARCHIVE_NAME}', 'foo', 'bar')
|
|
|
|
|
|
|
|
|
def test_create_archive_calls_borg_with_parameters():
|
|
@@ -292,9 +292,12 @@ def test_create_archive_calls_borg_with_parameters():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -327,10 +330,13 @@ def test_create_archive_calls_borg_with_environment():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
environment = {'BORG_THINGY': 'YUP'}
|
|
|
flexmock(module.environment).should_receive('make_environment').and_return(environment)
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -366,9 +372,12 @@ def test_create_archive_with_patterns_calls_borg_with_patterns():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(pattern_flags)
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + pattern_flags + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + pattern_flags + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -404,9 +413,12 @@ def test_create_archive_with_exclude_patterns_calls_borg_with_excludes():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(exclude_flags)
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + exclude_flags + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + exclude_flags + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -439,9 +451,12 @@ def test_create_archive_with_log_info_calls_borg_with_info_parameter():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--info') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--info') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -475,9 +490,12 @@ def test_create_archive_with_log_info_and_json_suppresses_most_borg_output():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--json') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=None,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -512,9 +530,12 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_parameter():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--debug', '--show-rc') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--debug', '--show-rc') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -548,9 +569,12 @@ def test_create_archive_with_log_debug_and_json_suppresses_most_borg_output():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--json') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=None,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -585,9 +609,12 @@ def test_create_archive_with_dry_run_calls_borg_with_dry_run_parameter():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--dry-run') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--dry-run') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -622,9 +649,12 @@ def test_create_archive_with_stats_and_dry_run_calls_borg_without_stats_paramete
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--info', '--dry-run') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--info', '--dry-run') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -659,9 +689,12 @@ def test_create_archive_with_checkpoint_interval_calls_borg_with_checkpoint_inte
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--checkpoint-interval', '600') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--checkpoint-interval', '600') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -694,9 +727,12 @@ def test_create_archive_with_chunker_params_calls_borg_with_chunker_params_param
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--chunker-params', '1,2,3,4') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--chunker-params', '1,2,3,4') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -729,9 +765,12 @@ def test_create_archive_with_compression_calls_borg_with_compression_parameters(
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--compression', 'rle') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--compression', 'rle') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -755,7 +794,7 @@ def test_create_archive_with_compression_calls_borg_with_compression_parameters(
|
|
|
@pytest.mark.parametrize(
|
|
|
'feature_available,option_flag', ((True, '--upload-ratelimit'), (False, '--remote-ratelimit')),
|
|
|
)
|
|
|
-def test_create_archive_with_remote_rate_limit_calls_borg_with_upload_ratelimit_parameters(
|
|
|
+def test_create_archive_with_upload_rate_limit_calls_borg_with_upload_ratelimit_parameters(
|
|
|
feature_available, option_flag
|
|
|
):
|
|
|
flexmock(module).should_receive('borgmatic_source_directories').and_return([])
|
|
@@ -769,9 +808,12 @@ def test_create_archive_with_remote_rate_limit_calls_borg_with_upload_ratelimit_
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', option_flag, '100') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', option_flag, '100') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -787,7 +829,7 @@ def test_create_archive_with_remote_rate_limit_calls_borg_with_upload_ratelimit_
|
|
|
'repositories': ['repo'],
|
|
|
'exclude_patterns': None,
|
|
|
},
|
|
|
- storage_config={'remote_rate_limit': 100},
|
|
|
+ storage_config={'upload_rate_limit': 100},
|
|
|
local_borg_version='1.2.3',
|
|
|
)
|
|
|
|
|
@@ -806,9 +848,12 @@ def test_create_archive_with_working_directory_calls_borg_with_working_directory
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -842,9 +887,12 @@ def test_create_archive_with_one_file_system_calls_borg_with_one_file_system_par
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--one-file-system') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--one-file-system') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -869,7 +917,7 @@ def test_create_archive_with_one_file_system_calls_borg_with_one_file_system_par
|
|
|
@pytest.mark.parametrize(
|
|
|
'feature_available,option_flag', ((True, '--numeric-ids'), (False, '--numeric-owner')),
|
|
|
)
|
|
|
-def test_create_archive_with_numeric_owner_calls_borg_with_numeric_ids_parameter(
|
|
|
+def test_create_archive_with_numeric_ids_calls_borg_with_numeric_ids_parameter(
|
|
|
feature_available, option_flag
|
|
|
):
|
|
|
flexmock(module).should_receive('borgmatic_source_directories').and_return([])
|
|
@@ -883,9 +931,12 @@ def test_create_archive_with_numeric_owner_calls_borg_with_numeric_ids_parameter
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', option_flag) + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', option_flag) + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -899,7 +950,7 @@ def test_create_archive_with_numeric_owner_calls_borg_with_numeric_ids_parameter
|
|
|
location_config={
|
|
|
'source_directories': ['foo', 'bar'],
|
|
|
'repositories': ['repo'],
|
|
|
- 'numeric_owner': True,
|
|
|
+ 'numeric_ids': True,
|
|
|
'exclude_patterns': None,
|
|
|
},
|
|
|
storage_config={},
|
|
@@ -919,9 +970,12 @@ def test_create_archive_with_read_special_calls_borg_with_read_special_parameter
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--read-special') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--read-special') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -962,9 +1016,12 @@ def test_create_archive_with_basic_option_calls_borg_with_corresponding_paramete
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + ((option_flag,) if option_flag else ()) + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + ((option_flag,) if option_flag else ()) + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1009,9 +1066,12 @@ def test_create_archive_with_atime_option_calls_borg_with_corresponding_paramete
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + ((option_flag,) if option_flag else ()) + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + ((option_flag,) if option_flag else ()) + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1042,7 +1102,7 @@ def test_create_archive_with_atime_option_calls_borg_with_corresponding_paramete
|
|
|
(False, False, '--nobsdflags'),
|
|
|
),
|
|
|
)
|
|
|
-def test_create_archive_with_bsd_flags_option_calls_borg_with_corresponding_parameter(
|
|
|
+def test_create_archive_with_flags_option_calls_borg_with_corresponding_parameter(
|
|
|
option_value, feature_available, option_flag
|
|
|
):
|
|
|
flexmock(module).should_receive('borgmatic_source_directories').and_return([])
|
|
@@ -1056,9 +1116,12 @@ def test_create_archive_with_bsd_flags_option_calls_borg_with_corresponding_para
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create') + ((option_flag,) if option_flag else ()) + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create') + ((option_flag,) if option_flag else ()) + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1072,7 +1135,7 @@ def test_create_archive_with_bsd_flags_option_calls_borg_with_corresponding_para
|
|
|
location_config={
|
|
|
'source_directories': ['foo', 'bar'],
|
|
|
'repositories': ['repo'],
|
|
|
- 'bsd_flags': option_value,
|
|
|
+ 'flags': option_value,
|
|
|
'exclude_patterns': None,
|
|
|
},
|
|
|
storage_config={},
|
|
@@ -1092,9 +1155,12 @@ def test_create_archive_with_files_cache_calls_borg_with_files_cache_parameters(
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--files-cache', 'ctime,size') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--files-cache', 'ctime,size') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1128,9 +1194,12 @@ def test_create_archive_with_local_path_calls_borg_via_local_path():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg1', 'create') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg1', 'create') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg1',
|
|
@@ -1164,9 +1233,12 @@ def test_create_archive_with_remote_path_calls_borg_with_remote_path_parameters(
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--remote-path', 'borg1') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--remote-path', 'borg1') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1200,9 +1272,12 @@ def test_create_archive_with_umask_calls_borg_with_umask_parameters():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--umask', '740') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--umask', '740') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1235,9 +1310,12 @@ def test_create_archive_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--lock-wait', '5') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--lock-wait', '5') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1270,9 +1348,12 @@ def test_create_archive_with_stats_calls_borg_with_stats_parameter_and_warning_o
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--stats') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--stats') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.WARNING,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1306,9 +1387,12 @@ def test_create_archive_with_stats_and_log_info_calls_borg_with_stats_parameter_
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--info', '--stats') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--info', '--stats') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1343,9 +1427,12 @@ def test_create_archive_with_files_calls_borg_with_list_parameter_and_warning_ou
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--list', '--filter', 'AME-') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--list', '--filter', 'AME-') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.WARNING,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1379,9 +1466,12 @@ def test_create_archive_with_files_and_log_info_calls_borg_with_list_parameter_a
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--list', '--filter', 'AME-', '--info') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--list', '--filter', 'AME-', '--info') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1416,9 +1506,12 @@ def test_create_archive_with_progress_and_log_info_calls_borg_with_progress_para
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--info', '--progress') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--info', '--progress') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=module.DO_NOT_CAPTURE,
|
|
|
borg_local_path='borg',
|
|
@@ -1453,9 +1546,12 @@ def test_create_archive_with_progress_calls_borg_with_progress_parameter():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--progress') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--progress') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=module.DO_NOT_CAPTURE,
|
|
|
borg_local_path='borg',
|
|
@@ -1490,10 +1586,13 @@ def test_create_archive_with_progress_and_stream_processes_calls_borg_with_progr
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
('borg', 'create', '--one-file-system', '--read-special', '--progress')
|
|
|
- + ARCHIVE_WITH_PATHS,
|
|
|
+ + REPO_ARCHIVE_WITH_PATHS,
|
|
|
processes=processes,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=module.DO_NOT_CAPTURE,
|
|
@@ -1529,9 +1628,12 @@ def test_create_archive_with_json_calls_borg_with_json_parameter():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--json') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=None,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1567,9 +1669,12 @@ def test_create_archive_with_stats_and_json_calls_borg_without_stats_parameter()
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--json') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--json') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=None,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1606,6 +1711,9 @@ def test_create_archive_with_source_directories_glob_expands():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'food'),
|
|
@@ -1642,6 +1750,9 @@ def test_create_archive_with_non_matching_source_directories_glob_passes_through
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo*'),
|
|
@@ -1678,6 +1789,9 @@ def test_create_archive_with_glob_calls_borg_with_expanded_directories():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'food'),
|
|
@@ -1713,6 +1827,9 @@ def test_create_archive_with_archive_name_format_calls_borg_with_archive_name():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ ('repo::ARCHIVE_NAME',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'create', 'repo::ARCHIVE_NAME', 'foo', 'bar'),
|
|
@@ -1737,6 +1854,7 @@ def test_create_archive_with_archive_name_format_calls_borg_with_archive_name():
|
|
|
|
|
|
|
|
|
def test_create_archive_with_archive_name_format_accepts_borg_placeholders():
|
|
|
+ repository_archive_pattern = 'repo::Documents_{hostname}-{now}'
|
|
|
flexmock(module).should_receive('borgmatic_source_directories').and_return([])
|
|
|
flexmock(module).should_receive('deduplicate_directories').and_return(('foo', 'bar'))
|
|
|
flexmock(module).should_receive('map_directories_to_devices').and_return({})
|
|
@@ -1748,9 +1866,12 @@ def test_create_archive_with_archive_name_format_accepts_borg_placeholders():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (repository_archive_pattern,)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', 'repo::Documents_{hostname}-{now}', 'foo', 'bar'),
|
|
|
+ ('borg', 'create', repository_archive_pattern, 'foo', 'bar'),
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1772,6 +1893,7 @@ def test_create_archive_with_archive_name_format_accepts_borg_placeholders():
|
|
|
|
|
|
|
|
|
def test_create_archive_with_repository_accepts_borg_placeholders():
|
|
|
+ repository_archive_pattern = '{fqdn}::Documents_{hostname}-{now}'
|
|
|
flexmock(module).should_receive('borgmatic_source_directories').and_return([])
|
|
|
flexmock(module).should_receive('deduplicate_directories').and_return(('foo', 'bar'))
|
|
|
flexmock(module).should_receive('map_directories_to_devices').and_return({})
|
|
@@ -1783,9 +1905,12 @@ def test_create_archive_with_repository_accepts_borg_placeholders():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (repository_archive_pattern,)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '{fqdn}::Documents_{hostname}-{now}', 'foo', 'bar'),
|
|
|
+ ('borg', 'create', repository_archive_pattern, 'foo', 'bar'),
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1818,9 +1943,12 @@ def test_create_archive_with_extra_borg_options_calls_borg_with_extra_options():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
- ('borg', 'create', '--extra', '--options') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--extra', '--options') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|
|
|
borg_local_path='borg',
|
|
@@ -1854,9 +1982,12 @@ def test_create_archive_with_stream_processes_calls_borg_with_processes():
|
|
|
flexmock(module).should_receive('ensure_files_readable')
|
|
|
flexmock(module).should_receive('make_pattern_flags').and_return(())
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ (f'repo::{DEFAULT_ARCHIVE_NAME}',)
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
- ('borg', 'create', '--one-file-system', '--read-special') + ARCHIVE_WITH_PATHS,
|
|
|
+ ('borg', 'create', '--one-file-system', '--read-special') + REPO_ARCHIVE_WITH_PATHS,
|
|
|
processes=processes,
|
|
|
output_log_level=logging.INFO,
|
|
|
output_file=None,
|