diff --git a/borgmatic/borg/environment.py b/borgmatic/borg/environment.py index 344478c2..0bee5711 100644 --- a/borgmatic/borg/environment.py +++ b/borgmatic/borg/environment.py @@ -79,6 +79,9 @@ def make_environment(config): os.set_inheritable(read_file_descriptor, True) environment['BORG_PASSPHRASE_FD'] = str(read_file_descriptor) + if 'use_chunks_archive' in config: + environment['BORG_USE_CHUNKS_ARCHIVE'] = 'yes' if config.get('use_chunks_archive') else 'no' + for ( option_name, environment_variable_name, diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 105f9b8e..f20490ca 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -389,6 +389,13 @@ properties: Path for Borg cache files. Defaults to $borg_base_directory/.cache/borg example: /path/to/base/cache + use_chunks_archive: + type: boolean + description: | + Enables or disables the use of chunks.archive.d for faster cache + resyncs in Borg. If true, value is set to "yes" (default) else + it's set to "no", reducing disk usage but slowing resyncs. + default: true borg_files_cache_ttl: type: integer description: | diff --git a/tests/unit/borg/test_environment.py b/tests/unit/borg/test_environment.py index 46bb33b7..093a0c6d 100644 --- a/tests/unit/borg/test_environment.py +++ b/tests/unit/borg/test_environment.py @@ -170,3 +170,13 @@ def test_make_environment_with_integer_variable_value(): environment = module.make_environment({'borg_files_cache_ttl': 40}) assert environment.get('BORG_FILES_CACHE_TTL') == '40' + + +def test_make_environment_with_use_chunks_archive_should_set_correct_environment_value(): + flexmock(module.os).should_receive('environ').and_return({'USER': 'root'}) + + environment = module.make_environment({'use_chunks_archive': True}) + assert environment.get('BORG_USE_CHUNKS_ARCHIVE') == 'yes' + + environment = module.make_environment({'use_chunks_archive': False}) + assert environment.get('BORG_USE_CHUNKS_ARCHIVE') == 'no'