Browse Source

Mention placeholders for repositories in documentation; fix #369

François Poulain 4 năm trước cách đây
mục cha
commit
ebac02f118

+ 4 - 2
borgmatic/config/schema.yaml

@@ -27,12 +27,14 @@ map:
                 desc: |
                 desc: |
                     Paths to local or remote repositories (required). Tildes are
                     Paths to local or remote repositories (required). Tildes are
                     expanded. Multiple repositories are backed up to in
                     expanded. Multiple repositories are backed up to in
-                    sequence. See ssh_command for SSH options like identity file
-                    or port.
+                    sequence. Borg placeholders can be used. See the output of
+                    "borg help placeholders" for details.
+                    See ssh_command for SSH options like identity file or port.
                     If systemd service is used, then add local repository paths
                     If systemd service is used, then add local repository paths
                     in the systemd service file to the ReadWritePaths list.
                     in the systemd service file to the ReadWritePaths list.
                 example:
                 example:
                     - user@backupserver:sourcehostname.borg
                     - user@backupserver:sourcehostname.borg
+                    - "user@backupserver:{fqdn}"
             one_file_system:
             one_file_system:
                 type: bool
                 type: bool
                 desc: |
                 desc: |

+ 28 - 0
tests/unit/borg/test_create.py

@@ -1326,6 +1326,34 @@ def test_create_archive_with_archive_name_format_accepts_borg_placeholders():
     )
     )
 
 
 
 
+def test_create_archive_with_repository_accepts_borg_placeholders():
+    flexmock(module).should_receive('borgmatic_source_directories').and_return([])
+    flexmock(module).should_receive('deduplicate_directories').and_return(('foo', 'bar'))
+    flexmock(module).should_receive('map_directories_to_devices').and_return({})
+    flexmock(module).should_receive('_expand_directories').and_return(())
+    flexmock(module).should_receive('_expand_home_directories').and_return(())
+    flexmock(module).should_receive('_write_pattern_file').and_return(None)
+    flexmock(module).should_receive('_make_pattern_flags').and_return(())
+    flexmock(module).should_receive('_make_exclude_flags').and_return(())
+    flexmock(module).should_receive('execute_command').with_args(
+        ('borg', 'create', '{fqdn}::Documents_{hostname}-{now}', 'foo', 'bar'),
+        output_log_level=logging.INFO,
+        output_file=None,
+        borg_local_path='borg',
+    )
+
+    module.create_archive(
+        dry_run=False,
+        repository='{fqdn}',
+        location_config={
+            'source_directories': ['foo', 'bar'],
+            'repositories': ['{fqdn}'],
+            'exclude_patterns': None,
+        },
+        storage_config={'archive_name_format': 'Documents_{hostname}-{now}'},
+    )
+
+
 def test_create_archive_with_extra_borg_options_calls_borg_with_extra_options():
 def test_create_archive_with_extra_borg_options_calls_borg_with_extra_options():
     flexmock(module).should_receive('borgmatic_source_directories').and_return([])
     flexmock(module).should_receive('borgmatic_source_directories').and_return([])
     flexmock(module).should_receive('deduplicate_directories').and_return(('foo', 'bar'))
     flexmock(module).should_receive('deduplicate_directories').and_return(('foo', 'bar'))