diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 7759bcb1..52cf0338 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -268,6 +268,7 @@ def make_base_create_command( # noqa: PLR0912 logger.debug('Checking file paths Borg plans to include') + find_special_files = bool(stream_processes and config.get('read_special') is False) special_file_paths = validate_planned_backup_paths( dry_run, create_flags + create_positional_arguments, @@ -276,16 +277,17 @@ def make_base_create_command( # noqa: PLR0912 local_path, working_directory, borgmatic_runtime_directory=borgmatic_runtime_directory, - find_special_files=bool(stream_processes and not config.get('read_special')), + find_special_files=find_special_files, ) - # If database hooks are enabled (as indicated by streaming processes), exclude files that might - # cause Borg to hang. But skip this if the user has explicitly set the "read_special" to True. - if special_file_paths: + if find_special_files: logger.warning( 'Ignoring configured "read_special" value of false, as true is needed for database hooks.', ) + # If database hooks are enabled (as indicated by streaming processes), exclude files that might + # cause Borg to hang. But skip this if the user has explicitly set the "read_special" to True. + if special_file_paths: truncated_special_file_paths = textwrap.shorten( ', '.join(special_file_paths), width=MAX_SPECIAL_FILE_PATHS_LENGTH, diff --git a/borgmatic/borg/list.py b/borgmatic/borg/list.py index 73e026ba..364074d3 100644 --- a/borgmatic/borg/list.py +++ b/borgmatic/borg/list.py @@ -221,22 +221,20 @@ def list_archive( ) # Ask Borg to list archives. Capture its output for use below. - archive_lines = tuple( - execute_command_and_capture_output( - repo_list.make_repo_list_command( - repository_path, - config, - local_borg_version, - repo_list_arguments, - global_arguments, - local_path, - remote_path, - ), - environment=environment.make_environment(config), - working_directory=borgmatic.config.paths.get_working_directory(config), - borg_local_path=local_path, - borg_exit_codes=borg_exit_codes, - ) + archive_lines = execute_command_and_capture_output( + repo_list.make_repo_list_command( + repository_path, + config, + local_borg_version, + repo_list_arguments, + global_arguments, + local_path, + remote_path, + ), + environment=environment.make_environment(config), + working_directory=borgmatic.config.paths.get_working_directory(config), + borg_local_path=local_path, + borg_exit_codes=borg_exit_codes, ) else: archive_lines = (list_arguments.archive,) diff --git a/borgmatic/hooks/data_source/lvm.py b/borgmatic/hooks/data_source/lvm.py index 545430b3..e625e609 100644 --- a/borgmatic/hooks/data_source/lvm.py +++ b/borgmatic/hooks/data_source/lvm.py @@ -44,7 +44,7 @@ def get_logical_volumes(lsblk_command, patterns=None): ''' try: devices_info = json.loads( - ''.join( + '\n'.join( borgmatic.execute.execute_command_and_capture_output( # Use lsblk instead of lvs here because lvs can't show active mounts. ( diff --git a/borgmatic/hooks/data_source/mariadb.py b/borgmatic/hooks/data_source/mariadb.py index 18884681..da324da6 100644 --- a/borgmatic/hooks/data_source/mariadb.py +++ b/borgmatic/hooks/data_source/mariadb.py @@ -158,17 +158,15 @@ def database_names_to_dump(database, config, username, password, environment, dr if skip_names: logger.debug(f'Skipping database names: {", ".join(skip_names)}') - show_output = '\n'.join( - execute_command_and_capture_output( - show_command, - environment=environment, - working_directory=borgmatic.config.paths.get_working_directory(config), - ) + show_lines = execute_command_and_capture_output( + show_command, + environment=environment, + working_directory=borgmatic.config.paths.get_working_directory(config), ) return tuple( - show_name - for show_name in show_output.strip().splitlines() + show_name.strip() + for show_name in show_lines if show_name not in SYSTEM_DATABASE_NAMES if not skip_names or show_name not in skip_names ) diff --git a/borgmatic/hooks/data_source/mysql.py b/borgmatic/hooks/data_source/mysql.py index 7cbe4108..3198a28c 100644 --- a/borgmatic/hooks/data_source/mysql.py +++ b/borgmatic/hooks/data_source/mysql.py @@ -87,17 +87,15 @@ def database_names_to_dump(database, config, username, password, environment, dr if skip_names: logger.debug(f'Skipping database names: {", ".join(skip_names)}') - show_output = '\n'.join( - execute_command_and_capture_output( - show_command, - environment=environment, - working_directory=borgmatic.config.paths.get_working_directory(config), - ) + show_lines = execute_command_and_capture_output( + show_command, + environment=environment, + working_directory=borgmatic.config.paths.get_working_directory(config), ) return tuple( - show_name - for show_name in show_output.strip().splitlines() + show_name.strip() + for show_name in show_lines if show_name not in SYSTEM_DATABASE_NAMES if not skip_names or show_name not in skip_names ) diff --git a/borgmatic/hooks/data_source/postgresql.py b/borgmatic/hooks/data_source/postgresql.py index 93463980..675913f0 100644 --- a/borgmatic/hooks/data_source/postgresql.py +++ b/borgmatic/hooks/data_source/postgresql.py @@ -103,17 +103,15 @@ def database_names_to_dump(database, config, environment, dry_run): + (tuple(database['list_options'].split(' ')) if 'list_options' in database else ()) ) logger.debug('Querying for "all" PostgreSQL databases to dump') - list_output = '\n'.join( - execute_command_and_capture_output( - list_command, - environment=environment, - working_directory=borgmatic.config.paths.get_working_directory(config), - ) + list_lines = execute_command_and_capture_output( + list_command, + environment=environment, + working_directory=borgmatic.config.paths.get_working_directory(config), ) return tuple( row[0] - for row in csv.reader(list_output.splitlines(), delimiter=',', quotechar='"') + for row in csv.reader(list_lines, delimiter=',', quotechar='"') if row[0] not in EXCLUDED_DATABASE_NAMES )