repo-create: store default compression and chunker params in the repository, fixes #346 - #10438
Merged
ThomasWaldmann merged 1 commit intoSep 27, 2026
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10438 +/- ##
==========================================
+ Coverage 88.62% 88.70% +0.07%
==========================================
Files 103 103
Lines 19229 19284 +55
Branches 2994 3004 +10
==========================================
+ Hits 17041 17105 +64
+ Misses 1522 1507 -15
- Partials 666 672 +6 ☔ View full report in Codecov by Harness. |
…sitory, fixes borgbackup#346 "borg repo-create --compression SPEC --chunker-params PARAMS" stores repository defaults in the new config/defaults store object. Compression: the commands that compress data (create, recreate, import-tar, transfer, repo-compress, debug put-obj) use the repository default if no compression was given via the command line, the environment or default.yaml; without a repository default, they use lz4 as before. Chunker params: "--chunker-params default" now means the repository default, else the built-in CHUNKER_PARAMS: ChunkerParams("default") returns the DEFAULT_CHUNKER_PARAMS marker and with_repository replaces it by the real chunker params. borg create and borg import-tar use the marker as their parser default, so they use the repository default if no chunker params were given. borg recreate and borg transfer still only rechunk if --chunker-params is given; with "default", they rechunk to the repository default. config/defaults is stored in the key's store object envelope, so it is authenticated: nobody without the key can change the defaults (e.g. remove an "obfuscate" compression) without being noticed. config/config can not hold them, as it is read before the key is known and is not authenticated. config/defaults is read at most once per Repository object. borg repo-info shows the defaults (also in --json). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ThomasWaldmann
force-pushed
the
repo-default-compression
branch
from
September 27, 2026 01:41
46853df to
f694ba3
Compare
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds per-repository defaults for compression and chunker params, fixes #346 (set at repository creation time).
What it does
borg repo-create --compression SPEC/--chunker-params PARAMSstore repository defaults.create,recreate,import-tar,transfer,repo-compress,debug put-obj) use the repository default if no compression was given.borg repo-compresswithout--compressionrecompresses to the repository default.createandimport-taruse the repository default if no chunker params were given.recreateandtransferstill only rechunk if--chunker-paramsis given;--chunker-params defaultnow means the repository default (else the built-in default) instead of always the built-in default.BORG_CREATE__COMPRESSION,BORG_CREATE__CHUNKER_PARAMS) ordefault.yamllz4,fastcdc,19,23,21,2), as beforeborg repo-infoshowsDefault compression: …andDefault chunker params: …(with(built-in)if the repository has no default);--jsonhas a newdefaultskey.Storage
The defaults are stored in a new
config/defaultsstore object (msgpacked dict of strings, e.g.{"compression": "zstd,3", "chunker_params": "fastcdc,19,23,21,2"}) in the key's store object envelope, like theindex/andcache/objects. So they are authenticated: nobody without the key can change them (e.g. remove anobfuscatecompression, or turn compression on wherenonewas chosen) without being noticed.config/configcan not hold them: it is read before the key is known and is not authenticated.IntegrityErrorInvalidRepositoryConfig(rc 16), the message names the problemThe resolution happens in one place, the
with_repositorydecorator (default_compression()/default_chunker_params()inarchiver/_common.py).--compressionoptions default toNone;ChunkerParams("default")returns aDEFAULT_CHUNKER_PARAMSmarker, which is also the parser default ofcreateandimport-tar.config/defaultsis read at most once perRepositoryobject.Not in this PR
repo-createsets them).borg checkdoes not verifyconfig/defaults; every command using it (incl.repo-info) authenticates it.Docs / tests
Docs: repo-create epilog ("Repository defaults"),
-C/--chunker-paramshelp texts,borg help compression,data-structures.rst(new "Repository defaults" section),frontends.rst, quickstart. Usage docs are not regenerated.New tests in
repo_create_cmd_test.py: defaults used by create/repo-compress/recreate, precedence (command line, env), built-in fallbacks,--chunker-params default, invalid values at creation, tampered and invalid stored defaults. Full test suite passes locally (macOS, Python 3.15).🤖 Generated with Claude Code