new BORG_UNITS env var: si / iec / raw size formatting, #5513 - #9977
Merged
Conversation
ThomasWaldmann
force-pushed
the
units-5513
branch
from
July 30, 2026 18:57
3f52b74 to
68b18ef
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9977 +/- ##
==========================================
+ Coverage 85.83% 85.84% +0.01%
==========================================
Files 95 95
Lines 17034 17056 +22
Branches 2607 2614 +7
==========================================
+ Hits 14621 14642 +21
- Misses 1673 1674 +1
Partials 740 740 ☔ View full report in Codecov by Harness. |
BORG_UNITS determines how borg formats sizes in human-readable output: - si (default): decimal units, e.g. 1.23 MB (1kB = 1000B) - iec: binary units, e.g. 1.18 MiB (1KiB = 1024B) - raw: exact byte counts, e.g. 1234567 B raw is meant for scripts (e.g. monitoring) that want to parse sizes without having to deal with scaled values and units. An invalid BORG_UNITS value is warned about (once) and ignored. BORG_IEC was removed, use BORG_UNITS=iec. format_file_size now determines the units itself (via BORG_UNITS), so the iec argument plumbing through Archive / Statistics / ArchiveFormatter / Cache / ArchiveChecker / ArchiveGarbageCollector and use_iec_units() are all gone. Beside being less code, this also makes the setting effective at the call sites that never passed iec=use_iec_units(), e.g. borg repo-space.
ThomasWaldmann
force-pushed
the
units-5513
branch
from
July 30, 2026 19:32
359d68a to
3a864cd
Compare
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.
Fixes #5513.
BORG_UNITSdetermines how borg formats sizes in human-readable output:si(default): decimal units, e.g.1.23 MB(1kB = 1000B)iec: binary units, e.g.1.18 MiB(1KiB = 1024B)raw: exact byte counts, e.g.1234567 Brawis what #5513 asked for: sizes that a script (e.g. for monitoring) can parse withouthaving to deal with scaled values and different units. It applies to all human-readable size
output, e.g.:
Note that
borg compact --statsusesprecision=0, so it printed e.g.Repository size is 2 MBbefore - withBORG_UNITS=rawthe exact value is not lost.BORG_IECwas removed, useBORG_UNITS=iecinstead. An invalidBORG_UNITSvalue iswarned about (once) and ignored.
Implementation notes:
get_size_units()resolves the units andformat_file_size()uses them, so the wholeiecargument plumbing through
Archive/Statistics/ArchiveFormatter/Cache/ArchiveChecker/ArchiveGarbageCollectoranduse_iec_units()could be removed. Besidebeing less code, this also makes the setting effective at the call sites that never passed
iec=use_iec_units(), e.g.borg repo-space.rawrounds floats (some callers format throughput values).scripts/make.py build_mancurrently regenerates all 48of them (they are stale for unrelated reasons, e.g. the return codes section and
borg-webdav), which would just add noise to this PR.Not part of this PR, but noticed while looking at the issue: for the repository size, which is
what the issue author actually wanted to monitor, there is still no machine-readable output at
all -
borg compact --statsandborg analyzeonly log human-readable text (no--json), andborg repo-infodoes not report sizes. Archive sizes are fine (borg info --json,borg list/repo-list --format "{size}"give byte counts).