Skip to content

create: support --stats with --dry-run - #10105

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:dryrun-stats-1648
Aug 15, 2026
Merged

create: support --stats with --dry-run#10105
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:dryrun-stats-1648

Conversation

@ThomasWaldmann

@ThomasWaldmann ThomasWaldmann commented Aug 14, 2026

Copy link
Copy Markdown
Member

Fixes #1648, fixes #4131.

--stats (and --json) now work together with --dry-run for borg create.

A dry run already walks all files and stat()s them, so it can cheaply count the files and sum up their sizes from file system metadata, without reading any file contents — the dry run stays as fast as before.

Text output:

Number of files: 3
Original size: 1.33 MB

--json returns "dry_run": true and a reduced stats object (nfiles, original_size) instead of the archive object (documented in frontends.rst).

Notes on the numbers:

  • The deduplicated size is unknown in a dry run, as data is not read, chunked, and deduplicated.
  • Sizes of data read from stdin, from a command's output (--content-from-command), and from special files (--read-special) are unknown and counted as zero.
  • Hardlinks count once per link, as in a real create.

🤖 Generated with Claude Code

A dry run already walks the files and stats them, so it can cheaply
count the files and sum up their sizes from file system metadata,
without reading any file contents.

--stats (and --json) with --dry-run now report the number of files
and the original size. The deduplicated size is unknown in a dry run,
as data is not read, chunked, and deduplicated. The sizes of data read
from stdin, from a command's output, and from special files are also
unknown in a dry run and counted as zero. Hardlinks count once per
link, as in a real create.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.57143% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.98%. Comparing base (e15404a) to head (448f1c6).
⚠️ Report is 11 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/archiver/create_cmd.py 50.00% 12 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10105      +/-   ##
==========================================
- Coverage   87.01%   86.98%   -0.03%     
==========================================
  Files          99      100       +1     
  Lines       17615    17684      +69     
  Branches     2664     2674      +10     
==========================================
+ Hits        15327    15382      +55     
- Misses       1593     1606      +13     
- Partials      695      696       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann
ThomasWaldmann merged commit ebf483d into borgbackup:master Aug 15, 2026
18 of 20 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the dryrun-stats-1648 branch August 15, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: "--pre-stats" option for create Allow borg create --dry-run --stats

1 participant