diff --git a/NEWS b/NEWS index b030ee76..138d08ab 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +1.2.10 + * #105: Support for Borg --chunker-params create option via "chunker_params" in borgmatic's storage + section. + 1.2.9 * #102: Fix for syntax error that occurred in Python 3.5 and below. * Make automated tests support running in Python 3.5. diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 51504b27..cad0a294 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -115,6 +115,7 @@ def create_archive( pattern_file = _write_pattern_file(location_config.get('patterns')) exclude_file = _write_pattern_file(_expand_directories(location_config.get('exclude_patterns'))) checkpoint_interval = storage_config.get('checkpoint_interval', None) + chunker_params = storage_config.get('chunker_params', None) compression = storage_config.get('compression', None) remote_rate_limit = storage_config.get('remote_rate_limit', None) umask = storage_config.get('umask', None) @@ -135,6 +136,7 @@ def create_archive( + _make_pattern_flags(location_config, pattern_file.name if pattern_file else None) + _make_exclude_flags(location_config, exclude_file.name if exclude_file else None) + (('--checkpoint-interval', str(checkpoint_interval)) if checkpoint_interval else ()) + + (('--chunker-params', chunker_params) if chunker_params else ()) + (('--compression', compression) if compression else ()) + (('--remote-ratelimit', str(remote_rate_limit)) if remote_rate_limit else ()) + (('--one-file-system',) if location_config.get('one_file_system') else ()) diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 19335367..a5b49d32 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -138,6 +138,13 @@ map: https://borgbackup.readthedocs.io/en/stable/faq.html#if-a-backup-stops-mid-way-does-the-already-backed-up-data-stay-there for details. Defaults to checkpoints every 1800 seconds (30 minutes). example: 1800 + chunker_params: + type: scalar + desc: | + Specify the parameters passed to then chunker (CHUNK_MIN_EXP, CHUNK_MAX_EXP, + HASH_MASK_BITS, HASH_WINDOW_SIZE). See https://borgbackup.readthedocs.io/en/stable/internals.html + for details. + example: 19,23,21,4095 compression: type: scalar desc: | diff --git a/setup.py b/setup.py index 1dfdf624..cfff3d5e 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages -VERSION = '1.2.9' +VERSION = '1.2.10' setup( diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index 8b739b16..2b3db1f9 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -390,6 +390,25 @@ def test_create_archive_with_checkpoint_interval_calls_borg_with_checkpoint_inte ) +def test_create_archive_with_chunker_params_calls_borg_with_chunker_params_parameters(): + flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')).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(()) + insert_subprocess_mock(CREATE_COMMAND + ('--chunker-params', '1,2,3,4')) + + module.create_archive( + dry_run=False, + repository='repo', + location_config={ + 'source_directories': ['foo', 'bar'], + 'repositories': ['repo'], + 'exclude_patterns': None, + }, + storage_config={'chunker_params': '1,2,3,4'}, + ) + + def test_create_archive_with_compression_calls_borg_with_compression_parameters(): flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')).and_return(()) flexmock(module).should_receive('_write_pattern_file').and_return(None)