From 7bb27e5366ebcfea85f648c04e449ca2579b581d Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sun, 11 Jan 2026 09:51:50 -0800 Subject: [PATCH] Revert "Fix for incorrect use of "--log-json" when looking up latest archive (#1204)." This reverts commit 2c530cc1b9c503487df4c20eb92a768ff3d317ad. --- borgmatic/actions/check.py | 4 ++-- borgmatic/borg/repo_list.py | 1 + tests/unit/borg/test_repo_list.py | 26 ++++++++++++++------------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/borgmatic/actions/check.py b/borgmatic/actions/check.py index c25f7418..187a7cfa 100644 --- a/borgmatic/actions/check.py +++ b/borgmatic/actions/check.py @@ -602,6 +602,8 @@ def spot_check( disk to those stored in the latest archive. If any differences are beyond configured tolerances, then the check fails. ''' + logger.debug('Running spot check') + try: spot_check_config = next( check for check in config.get('checks', ()) if check.get('name') == 'spot' @@ -786,7 +788,6 @@ def run_check( write_check_time(make_check_time_path(config, repository_id, check, archives_check_id)) if 'extract' in checks: - logger.info('Running extract check') borgmatic.borg.extract.extract_last_archive_dry_run( config, local_borg_version, @@ -800,7 +801,6 @@ def run_check( if 'spot' in checks: with borgmatic.config.paths.Runtime_directory(config) as borgmatic_runtime_directory: - logger.info('Running spot check') spot_check( repository, config, diff --git a/borgmatic/borg/repo_list.py b/borgmatic/borg/repo_list.py index cbc28f58..446aacad 100644 --- a/borgmatic/borg/repo_list.py +++ b/borgmatic/borg/repo_list.py @@ -77,6 +77,7 @@ def get_latest_archive( ), *flags.make_flags('remote-path', remote_path), *flags.make_flags('umask', config.get('umask')), + *('--log-json',), *flags.make_flags('lock-wait', config.get('lock_wait')), *( flags.make_flags('consider-checkpoints', consider_checkpoints) diff --git a/tests/unit/borg/test_repo_list.py b/tests/unit/borg/test_repo_list.py index 0a5ea6d1..6944a0b7 100644 --- a/tests/unit/borg/test_repo_list.py +++ b/tests/unit/borg/test_repo_list.py @@ -119,7 +119,7 @@ def test_get_latest_archive_calls_borg_with_flags(): flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), borg_local_path='borg', borg_exit_codes=None, environment=None, @@ -148,7 +148,7 @@ def test_get_latest_archive_with_log_info_calls_borg_without_info_flag(): flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -178,7 +178,7 @@ def test_get_latest_archive_with_log_debug_calls_borg_without_debug_flag(): flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -208,7 +208,7 @@ def test_get_latest_archive_with_local_path_calls_borg_via_local_path(): flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg1', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg1', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg1', @@ -239,7 +239,7 @@ def test_get_latest_archive_with_exit_codes_calls_borg_using_them(): flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) borg_exit_codes = flexmock() flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -271,7 +271,7 @@ def test_get_latest_archive_with_remote_path_calls_borg_with_remote_path_flags() flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', '--remote-path', 'borg1', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--remote-path', 'borg1', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -304,7 +304,7 @@ def test_get_latest_archive_with_umask_calls_borg_with_umask_flags(): flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', '--umask', '077', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--umask', '077', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -332,7 +332,7 @@ def test_get_latest_archive_without_archives_raises(): flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',)) flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -362,7 +362,7 @@ def test_get_latest_archive_with_lock_wait_calls_borg_with_lock_wait_flags(): flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', '--lock-wait', 'okay', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', '--lock-wait', 'okay', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -394,6 +394,7 @@ def test_get_latest_archive_calls_borg_with_list_extra_borg_options(): ( 'borg', 'list', + '--log-json', *BORG_LIST_LATEST_ARGUMENTS[:-1], '--extra', 'value with space', @@ -430,6 +431,7 @@ def test_get_latest_archive_with_feature_available_calls_borg_with_repo_list_ext ( 'borg', 'repo-list', + '--log-json', *BORG_LIST_LATEST_ARGUMENTS[:-1], '--extra', 'value with space', @@ -466,7 +468,7 @@ def test_get_latest_archive_with_consider_checkpoints_calls_borg_with_consider_c flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', '--consider-checkpoints', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', '--consider-checkpoints', *BORG_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -499,7 +501,7 @@ def test_get_latest_archive_with_consider_checkpoints_and_feature_available_call flexmock(module.environment).should_receive('make_environment') flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'repo-list', *BORG_REPO_LIST_LATEST_ARGUMENTS), + ('borg', 'repo-list', '--log-json', *BORG_REPO_LIST_LATEST_ARGUMENTS), environment=None, working_directory=None, borg_local_path='borg', @@ -531,7 +533,7 @@ def test_get_latest_archive_calls_borg_with_working_directory(): '/working/dir', ) flexmock(module).should_receive('execute_command_and_capture_output').with_args( - ('borg', 'list', *BORG_LIST_LATEST_ARGUMENTS), + ('borg', 'list', '--log-json', *BORG_LIST_LATEST_ARGUMENTS), borg_local_path='borg', borg_exit_codes=None, environment=None,