From ad21eb41ae0ed252b8bcbfcb5827bedf2b52a349 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 23 Oct 2024 11:10:40 -0700 Subject: [PATCH] Add support for Borg 2's "rclone://" repository URLs. --- NEWS | 2 ++ borgmatic/config/normalize.py | 6 ++++-- tests/unit/config/test_normalize.py | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0be89120..b0da2ca1 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ * #911: Add a "key change-passphrase" action to change the passphrase protecting a repository key. * #921: BREAKING: Change soft failure command hooks to skip only the current repository rather than all repositories in the configuration file. + * Add support for Borg 2's "rclone://" repository URLs, so you can backup to 70+ cloud storage + services whether or not they support Borg explicitly. 1.8.14 * #896: Fix an error in borgmatic rcreate/init on an empty repository directory with Borg 1.4. diff --git a/borgmatic/config/normalize.py b/borgmatic/config/normalize.py index cbad9a8c..9f732355 100644 --- a/borgmatic/config/normalize.py +++ b/borgmatic/config/normalize.py @@ -233,7 +233,9 @@ def normalize(config_filename, config): path=updated_repository_path, ) ) - elif repository_path.startswith('ssh://'): + elif repository_path.startswith('ssh://') or repository_path.startswith( + 'rclone://' + ): config['repositories'].append(repository_dict) else: rewritten_repository_path = f"ssh://{repository_path.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}" @@ -242,7 +244,7 @@ def normalize(config_filename, config): dict( levelno=logging.WARNING, levelname='WARNING', - msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated and support will be removed from a future release. Interpreting "{repository_path}" as "{rewritten_repository_path}"', + msg=f'{config_filename}: Remote repository paths without ssh:// or rclone:// syntax are deprecated and support will be removed from a future release. Interpreting "{repository_path}" as "{rewritten_repository_path}"', ) ) ) diff --git a/tests/unit/config/test_normalize.py b/tests/unit/config/test_normalize.py index 699bb4da..ada7a089 100644 --- a/tests/unit/config/test_normalize.py +++ b/tests/unit/config/test_normalize.py @@ -211,6 +211,11 @@ def test_normalize_sections_with_only_scalar_raises(): {'repositories': [{'path': 'ssh://foo@bar:1234/repo'}]}, True, ), + ( + {'repositories': ['rclone://host:/repo']}, + {'repositories': [{'path': 'rclone://host:/repo'}]}, + True, + ), ( {'repositories': ['file:///repo']}, {'repositories': [{'path': '/repo'}]},