浏览代码

Support for Borg --keep-exclude-tags and --exclude-nodump options (#234).

Dan Helfman 5 年之前
父节点
当前提交
f48f52079d
共有 5 个文件被更改,包括 50 次插入2 次删除
  1. 3 0
      NEWS
  2. 11 1
      borgmatic/borg/create.py
  3. 11 0
      borgmatic/config/schema.yaml
  4. 1 1
      setup.py
  5. 24 0
      tests/unit/borg/test_create.py

+ 3 - 0
NEWS

@@ -1,3 +1,6 @@
+1.4.4
+ * #234: Support for Borg --keep-exclude-tags and --exclude-nodump options.
+
 1.4.3
 1.4.3
  * Monitor backups with Cronitor hook integration. See the documentation for more information:
  * Monitor backups with Cronitor hook integration. See the documentation for more information:
    https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#cronitor-hook
    https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#cronitor-hook

+ 11 - 1
borgmatic/borg/create.py

@@ -90,8 +90,18 @@ def _make_exclude_flags(location_config, exclude_filename=None):
     caches_flag = ('--exclude-caches',) if location_config.get('exclude_caches') else ()
     caches_flag = ('--exclude-caches',) if location_config.get('exclude_caches') else ()
     if_present = location_config.get('exclude_if_present')
     if_present = location_config.get('exclude_if_present')
     if_present_flags = ('--exclude-if-present', if_present) if if_present else ()
     if_present_flags = ('--exclude-if-present', if_present) if if_present else ()
+    keep_exclude_tags_flags = (
+        ('--keep-exclude-tags',) if location_config.get('keep_exclude_tags') else ()
+    )
+    exclude_nodump_flags = ('--exclude-nodump',) if location_config.get('exclude_nodump') else ()
 
 
-    return exclude_from_flags + caches_flag + if_present_flags
+    return (
+        exclude_from_flags
+        + caches_flag
+        + if_present_flags
+        + keep_exclude_tags_flags
+        + exclude_nodump_flags
+    )
 
 
 
 
 BORGMATIC_SOURCE_DIRECTORY = '~/.borgmatic'
 BORGMATIC_SOURCE_DIRECTORY = '~/.borgmatic'

+ 11 - 0
borgmatic/config/schema.yaml

@@ -126,6 +126,17 @@ map:
                     Exclude directories that contain a file with the given filename. Defaults to not
                     Exclude directories that contain a file with the given filename. Defaults to not
                     set.
                     set.
                 example: .nobackup
                 example: .nobackup
+            keep_exclude_tags:
+                type: bool
+                desc: |
+                    If true, the exclude_if_present filename is included in backups. Defaults to
+                    false, meaning that the exclude_if_present filename is omitted from backups.
+                example: true
+            exclude_nodump:
+                type: bool
+                desc: |
+                    Exclude files with the NODUMP flag. Defaults to false.
+                example: true
     storage:
     storage:
         desc: |
         desc: |
             Repository storage options. See
             Repository storage options. See

+ 1 - 1
setup.py

@@ -1,6 +1,6 @@
 from setuptools import find_packages, setup
 from setuptools import find_packages, setup
 
 
-VERSION = '1.4.3'
+VERSION = '1.4.4'
 
 
 
 
 setup(
 setup(

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

@@ -150,6 +150,30 @@ def test_make_exclude_flags_includes_exclude_if_present_when_in_config():
     assert exclude_flags == ('--exclude-if-present', 'exclude_me')
     assert exclude_flags == ('--exclude-if-present', 'exclude_me')
 
 
 
 
+def test_make_exclude_flags_includes_keep_exclude_tags_when_true_in_config():
+    exclude_flags = module._make_exclude_flags(location_config={'keep_exclude_tags': True})
+
+    assert exclude_flags == ('--keep-exclude-tags',)
+
+
+def test_make_exclude_flags_does_not_include_keep_exclude_tags_when_false_in_config():
+    exclude_flags = module._make_exclude_flags(location_config={'keep_exclude_tags': False})
+
+    assert exclude_flags == ()
+
+
+def test_make_exclude_flags_includes_exclude_nodump_when_true_in_config():
+    exclude_flags = module._make_exclude_flags(location_config={'exclude_nodump': True})
+
+    assert exclude_flags == ('--exclude-nodump',)
+
+
+def test_make_exclude_flags_does_not_include_exclude_nodump_when_false_in_config():
+    exclude_flags = module._make_exclude_flags(location_config={'exclude_nodump': False})
+
+    assert exclude_flags == ()
+
+
 def test_make_exclude_flags_is_empty_when_config_has_no_excludes():
 def test_make_exclude_flags_is_empty_when_config_has_no_excludes():
     exclude_flags = module._make_exclude_flags(location_config={})
     exclude_flags = module._make_exclude_flags(location_config={})