diff --git a/borgmatic/borg/export_tar.py b/borgmatic/borg/export_tar.py index 5ed494c..28a876e 100644 --- a/borgmatic/borg/export_tar.py +++ b/borgmatic/borg/export_tar.py @@ -47,7 +47,11 @@ def export_tar_archive( + (('--tar-filter', tar_filter) if tar_filter else ()) + (('--strip-components', str(strip_components)) if strip_components else ()) + flags.make_repository_archive_flags( - repository if ':' in repository else os.path.abspath(repository), + os.path.abspath(repository) + if ':' not in repository + else os.path.abspath(repository[7:]) + if repository.startswith('file://') + else repository, archive, local_borg_version, ) diff --git a/borgmatic/borg/extract.py b/borgmatic/borg/extract.py index 8ea8bbb..be3c5b7 100644 --- a/borgmatic/borg/extract.py +++ b/borgmatic/borg/extract.py @@ -100,7 +100,11 @@ def extract_archive( + (('--progress',) if progress else ()) + (('--stdout',) if extract_to_stdout else ()) + flags.make_repository_archive_flags( - repository if ':' in repository else os.path.abspath(repository), + os.path.abspath(repository) + if ':' not in repository + else os.path.abspath(repository[7:]) + if repository.startswith('file://') + else repository, archive, local_borg_version, ) diff --git a/borgmatic/config/normalize.py b/borgmatic/config/normalize.py index 574a48a..7a25014 100644 --- a/borgmatic/config/normalize.py +++ b/borgmatic/config/normalize.py @@ -1,4 +1,5 @@ import logging +import os def normalize(config_filename, config): @@ -68,20 +69,23 @@ def normalize(config_filename, config): ) ) ) - if ':' in repository and not repository.startswith('ssh://'): - rewritten_repository = ( - f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}" - ) - logs.append( - logging.makeLogRecord( - dict( - levelno=logging.WARNING, - levelname='WARNING', - msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated. Interpreting "{repository}" as "{rewritten_repository}"', + if ':' in repository: + if repository.startswith('file://'): + config['location']['repositories'].append(os.path.abspath(repository[7:])) + elif repository.startswith('ssh://'): + config['location']['repositories'].append(repository) + else: + rewritten_repository = f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}" + logs.append( + logging.makeLogRecord( + dict( + levelno=logging.WARNING, + levelname='WARNING', + msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated. Interpreting "{repository}" as "{rewritten_repository}"', + ) ) ) - ) - config['location']['repositories'].append(rewritten_repository) + config['location']['repositories'].append(rewritten_repository) else: config['location']['repositories'].append(repository) diff --git a/borgmatic/config/validate.py b/borgmatic/config/validate.py index 3a2807f..d61f7f3 100644 --- a/borgmatic/config/validate.py +++ b/borgmatic/config/validate.py @@ -126,12 +126,15 @@ def normalize_repository_path(repository): ''' Given a repository path, return the absolute path of it (for local repositories). ''' - # A colon in the repository indicates it's a remote repository. Bail. - if ':' in repository: + # A colon in the repository could mean that it's either a file:// URL or a remote repository. + # If it's a remote repository, we don't want to normalize it. If it's a file:// URL, we do. + if ':' not in repository: + return os.path.abspath(repository) + elif repository.startswith('file://'): + return os.path.abspath(repository[7:]) + else: return repository - return os.path.abspath(repository) - def repositories_match(first, second): '''