Преглед изворни кода

Support for Borg --files-cache option for setting the files cache operation mode.

Dan пре 7 година
родитељ
комит
fc3b1fccba
4 измењених фајлова са 29 додато и 1 уклоњено
  1. 1 0
      NEWS
  2. 3 1
      borgmatic/borg/create.py
  3. 6 0
      borgmatic/config/schema.yaml
  4. 19 0
      borgmatic/tests/unit/borg/test_create.py

+ 1 - 0
NEWS

@@ -2,6 +2,7 @@
  * Pass several Unix signals through to child processes like Borg. This means that Borg now properly
    shuts down if borgmatic is terminated (e.g. due to a system suspend).
  * #29: Support for using tilde in repository paths to reference home directory.
+ * #42: Support for Borg --files-cache option for setting the files cache operation mode.
 
 1.1.9
  * #16, #38: Support for user-defined hooks before/after backup, or on error.

+ 3 - 1
borgmatic/borg/create.py

@@ -84,6 +84,8 @@ def create_archive(
     umask = storage_config.get('umask', None)
     umask_flags = ('--umask', str(umask)) if umask else ()
     one_file_system_flags = ('--one-file-system',) if location_config.get('one_file_system') else ()
+    files_cache = location_config.get('files_cache')
+    files_cache_flags = ('--files-cache', files_cache) if files_cache else ()
     remote_path = location_config.get('remote_path')
     remote_path_flags = ('--remote-path', remote_path) if remote_path else ()
     verbosity_flags = {
@@ -99,7 +101,7 @@ def create_archive(
             repository=repository,
             archive_name_format=archive_name_format,
         ),
-    ) + sources + exclude_flags + compression_flags + one_file_system_flags + \
+    ) + sources + exclude_flags + compression_flags + one_file_system_flags + files_cache_flags + \
         remote_path_flags + umask_flags + verbosity_flags
 
     subprocess.check_call(full_command)

+ 6 - 0
borgmatic/config/schema.yaml

@@ -22,6 +22,12 @@ map:
                 type: bool
                 desc: Stay in same file system (do not cross mount points).
                 example: true
+            files_cache:
+                type: scalar
+                desc: Mode in which to operate the files cache. See
+                      https://borgbackup.readthedocs.io/en/stable/usage/create.html#description for
+                      details.
+                example: ctime,size,inode
             remote_path:
                 type: scalar
                 desc: Alternate Borg remote executable. Defaults to "borg".

+ 19 - 0
borgmatic/tests/unit/borg/test_create.py

@@ -250,6 +250,25 @@ def test_create_archive_with_one_file_system_calls_borg_with_one_file_system_par
     )
 
 
+def test_create_archive_with_files_cache_calls_borg_with_files_cache_parameters():
+    flexmock(module).should_receive('_expand_directory').and_return(['foo']).and_return(['bar'])
+    flexmock(module).should_receive('_write_exclude_file').and_return(None)
+    flexmock(module).should_receive('_make_exclude_flags').and_return(())
+    insert_subprocess_mock(CREATE_COMMAND + ('--files-cache', 'ctime,size'))
+
+    module.create_archive(
+        verbosity=None,
+        repository='repo',
+        location_config={
+            'source_directories': ['foo', 'bar'],
+            'repositories': ['repo'],
+            'files_cache': 'ctime,size',
+            'exclude_patterns': None,
+        },
+        storage_config={},
+    )
+
+
 def test_create_archive_with_remote_path_calls_borg_with_remote_path_parameters():
     flexmock(module).should_receive('_expand_directory').and_return(['foo']).and_return(['bar'])
     flexmock(module).should_receive('_write_exclude_file').and_return(None)