From ac7c7d40368e85a67e1b12a79d33aa7b3c76f0bf Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 20 Sep 2022 13:52:13 -0700 Subject: [PATCH] Warn when ignoring a configured "read_special" value of false, as true is needed when database hooks are enabled (#587). --- NEWS | 4 ++++ borgmatic/borg/create.py | 5 ++++ setup.py | 2 +- tests/unit/borg/test_create.py | 44 ++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b8ad9e1cb..4da088da9 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +1.7.3 + * #587: Warn when ignoring a configured "read_special" value of false, as true is needed when + database hooks are enabled. + 1.7.2 * #577: Fix regression in which "borgmatic info --archive ..." showed repository info instead of archive info with Borg 1. diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 5d921396e..bfc44062f 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -295,6 +295,11 @@ def create_archive( ensure_files_readable(location_config.get('patterns_from'), location_config.get('exclude_from')) + if stream_processes and location_config.get('read_special') is False: + logger.warning( + f'{repository}: Ignoring configured "read_special" value of false, as true is needed for database hooks.' + ) + full_command = ( tuple(local_path.split(' ')) + ('create',) diff --git a/setup.py b/setup.py index ab32cbeed..379e1b36c 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.7.2' +VERSION = '1.7.3.dev0' setup( diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index 21feddb6c..b7328c37d 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -1673,6 +1673,50 @@ def test_create_archive_with_progress_and_stream_processes_calls_borg_with_progr ) +def test_create_archive_with_stream_processes_ignores_read_special_false_logs_warning(): + processes = flexmock() + 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({}) + flexmock(module).should_receive('expand_directories').and_return(()) + flexmock(module).should_receive('pattern_root_directories').and_return([]) + flexmock(module.os.path).should_receive('expanduser').and_raise(TypeError) + flexmock(module).should_receive('expand_home_directories').and_return(()) + flexmock(module).should_receive('write_pattern_file').and_return(None) + flexmock(module.feature).should_receive('available').and_return(True) + flexmock(module).should_receive('ensure_files_readable') + flexmock(module.logger).should_receive('warning').once() + 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') + REPO_ARCHIVE_WITH_PATHS, + processes=processes, + output_log_level=logging.INFO, + output_file=None, + borg_local_path='borg', + working_directory=None, + extra_environment=None, + ) + + module.create_archive( + dry_run=False, + repository='repo', + location_config={ + 'source_directories': ['foo', 'bar'], + 'repositories': ['repo'], + 'exclude_patterns': None, + 'read_special': False, + }, + storage_config={}, + local_borg_version='1.2.3', + stream_processes=processes, + ) + + def test_create_archive_with_json_calls_borg_with_json_parameter(): flexmock(module).should_receive('borgmatic_source_directories').and_return([]) flexmock(module).should_receive('deduplicate_directories').and_return(('foo', 'bar'))