Browse Source

Add support for Borg 2's "rclone://" repository URLs.

Dan Helfman 8 months ago
parent
commit
ad21eb41ae
3 changed files with 11 additions and 2 deletions
  1. 2 0
      NEWS
  2. 4 2
      borgmatic/config/normalize.py
  3. 5 0
      tests/unit/config/test_normalize.py

+ 2 - 0
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.

+ 4 - 2
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}"',
                             )
                         )
                     )

+ 5 - 0
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'}]},