From 04e5b426064da10cb729c75625ed34aa4c28f4bd Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 12 Nov 2019 11:47:24 -0800 Subject: [PATCH] Fix repository does not exist error with "borgmatic extract" when repository is remote (#243). --- NEWS | 1 + borgmatic/borg/extract.py | 6 +++--- tests/unit/borg/test_extract.py | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 1132059..5e6b21d 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 1.4.9.dev0 * #228: Database dump hooks for MySQL/MariaDB, so you can easily dump your databases before backups run. + * #243: Fix repository does not exist error with "borgmatic extract" when repository is remote. 1.4.8 * Monitor backups with Cronhub hook integration. See the documentation for more information: diff --git a/borgmatic/borg/extract.py b/borgmatic/borg/extract.py index 7ed2967..7a32ef6 100644 --- a/borgmatic/borg/extract.py +++ b/borgmatic/borg/extract.py @@ -83,7 +83,7 @@ def extract_archive( + (('--debug', '--list', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ()) + (('--dry-run',) if dry_run else ()) + (('--progress',) if progress else ()) - + ('::'.join((os.path.abspath(repository), archive)),) + + ('::'.join((repository if ':' in repository else os.path.abspath(repository), archive)),) + (tuple(paths) if paths else ()) ) @@ -95,8 +95,8 @@ def extract_archive( ) return - # Error on warnings, as Borg only gives a warning if the restore paths don't exist in the - # archive! + # Error on warnings by default, as Borg only gives a warning if the restore paths don't exist in + # the archive! execute_command( full_command, working_directory=destination_path, error_on_warnings=error_on_warnings ) diff --git a/tests/unit/borg/test_extract.py b/tests/unit/borg/test_extract.py index 1459d53..e298ed2 100644 --- a/tests/unit/borg/test_extract.py +++ b/tests/unit/borg/test_extract.py @@ -236,3 +236,19 @@ def test_extract_archive_calls_borg_with_progress_parameter(): storage_config={}, progress=True, ) + + +def test_extract_archive_skips_abspath_for_remote_repository(): + flexmock(module.os.path).should_receive('abspath').never() + flexmock(module).should_receive('execute_command').with_args( + ('borg', 'extract', 'server:repo::archive'), working_directory=None, error_on_warnings=True + ).once() + + module.extract_archive( + dry_run=False, + repository='server:repo', + archive='archive', + paths=None, + location_config={}, + storage_config={}, + )