Răsfoiți Sursa

Support for Borg --noatime, --noctime, and --nobirthtime flags (mentioned in #193).

Dan Helfman 6 ani în urmă
părinte
comite
4444219e17
5 a modificat fișierele cu 27 adăugiri și 7 ștergeri
  1. 3 1
      NEWS
  2. 3 0
      borgmatic/borg/create.py
  3. 12 0
      borgmatic/config/schema.yaml
  4. 1 1
      setup.py
  5. 8 5
      tests/unit/borg/test_create.py

+ 3 - 1
NEWS

@@ -1,8 +1,10 @@
-1.3.11.dev0
+1.3.11
  * #193: Pass through several "borg list" and "borg info" flags like --short, --format, --sort-by,
    --first, --last, etc. via borgmatic command-line flags.
  * Add borgmatic info --repository and --archive command-line flags to display info for individual
    repositories or archives.
+ * Support for Borg --noatime, --noctime, and --nobirthtime flags via corresponding options in
+   borgmatic configuration location section.
 
 1.3.10
  * #198: Fix for Borg create error output not showing up at borgmatic verbosity level zero.

+ 3 - 0
borgmatic/borg/create.py

@@ -142,6 +142,9 @@ def create_archive(
         + (('--remote-ratelimit', str(remote_rate_limit)) if remote_rate_limit else ())
         + (('--one-file-system',) if location_config.get('one_file_system') else ())
         + (('--numeric-owner',) if location_config.get('numeric_owner') else ())
+        + (('--noatime',) if location_config.get('atime') is False else ())
+        + (('--noctime',) if location_config.get('ctime') is False else ())
+        + (('--nobirthtime',) if location_config.get('birthtime') is False else ())
         + (('--read-special',) if location_config.get('read_special') else ())
         + (('--nobsdflags',) if location_config.get('bsd_flags') is False else ())
         + (('--files-cache', files_cache) if files_cache else ())

+ 12 - 0
borgmatic/config/schema.yaml

@@ -36,6 +36,18 @@ map:
                 type: bool
                 desc: Only store/extract numeric user and group identifiers. Defaults to false.
                 example: true
+            atime:
+                type: bool
+                desc: Store atime into archive. Defaults to true.
+                example: false
+            ctime:
+                type: bool
+                desc: Store ctime into archive. Defaults to true.
+                example: false
+            birthtime:
+                type: bool
+                desc: Store birthtime (creation date) into archive. Defaults to true.
+                example: false
             read_special:
                 type: bool
                 desc: |

+ 1 - 1
setup.py

@@ -1,6 +1,6 @@
 from setuptools import find_packages, setup
 
-VERSION = '1.3.11.dev0'
+VERSION = '1.3.11'
 
 
 setup(

+ 8 - 5
tests/unit/borg/test_create.py

@@ -1,5 +1,6 @@
 import logging
 
+import pytest
 from flexmock import flexmock
 
 from borgmatic.borg import create as module
@@ -563,7 +564,8 @@ def test_create_archive_with_read_special_calls_borg_with_read_special_parameter
     )
 
 
-def test_create_archive_with_bsd_flags_true_calls_borg_without_nobsdflags_parameter():
+@pytest.mark.parametrize('option_name', ('atime', 'ctime', 'birthtime', 'bsd_flags'))
+def test_create_archive_with_option_true_calls_borg_without_corresponding_parameter(option_name):
     flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar'))
     flexmock(module).should_receive('_expand_home_directories').and_return(())
     flexmock(module).should_receive('_write_pattern_file').and_return(None)
@@ -579,21 +581,22 @@ def test_create_archive_with_bsd_flags_true_calls_borg_without_nobsdflags_parame
         location_config={
             'source_directories': ['foo', 'bar'],
             'repositories': ['repo'],
-            'bsd_flags': True,
+            option_name: True,
             'exclude_patterns': None,
         },
         storage_config={},
     )
 
 
-def test_create_archive_with_bsd_flags_false_calls_borg_with_nobsdflags_parameter():
+@pytest.mark.parametrize('option_name', ('atime', 'ctime', 'birthtime', 'bsd_flags'))
+def test_create_archive_with_option_false_calls_borg_with_corresponding_parameter(option_name):
     flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar'))
     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(
-        CREATE_COMMAND + ('--nobsdflags',), output_log_level=logging.INFO
+        CREATE_COMMAND + ('--no' + option_name.replace('_', ''),), output_log_level=logging.INFO
     )
 
     module.create_archive(
@@ -602,7 +605,7 @@ def test_create_archive_with_bsd_flags_false_calls_borg_with_nobsdflags_paramete
         location_config={
             'source_directories': ['foo', 'bar'],
             'repositories': ['repo'],
-            'bsd_flags': False,
+            option_name: False,
             'exclude_patterns': None,
         },
         storage_config={},