From 958495425e7f8291244b2ed9fe29fce9abe04fb8 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 5 Nov 2026 22:34:18 +0100 Subject: [PATCH] recreate: show --stats output without --info ArchiveRecreater.save logged the statistics via the default logger at INFO level, so "borg recreate --stats" printed nothing unless --info or -v was also given. Log them to the borg.output.stats topic logger, which --stats enables, like create, delete and prune do. Co-Authored-By: Claude Opus 5.5 --- src/borg/archive.py | 3 ++- src/borg/testsuite/archiver.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 56375a70d3..3625faa9ab 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -1,5 +1,6 @@ import errno import json +import logging import os import socket import stat @@ -2565,7 +2566,7 @@ def save(self, archive, target, comment=None, replace_original=True): DASHES, str(target.stats), str(self.cache), - DASHES) + DASHES, logger=logging.getLogger('borg.output.stats')) def matcher_add_tagged_dirs(self, archive): """Add excludes to the matcher created by exclude_cache and exclude_if_present.""" diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index 1047d6f1eb..57eaa61246 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -4067,6 +4067,22 @@ def test_recreate_list_output(self): self.assert_not_in("input/file1", output) self.assert_not_in("x input/file5", output) + def test_recreate_stats(self): + self.cmd('init', '--encryption=repokey', self.repository_location) + self.create_regular_file('file1', size=1024) + self.create_regular_file('file2', size=1024) + self.cmd('create', self.repository_location + '::test', 'input') + # --stats must show the statistics without also giving --info. + output = self.cmd('recreate', '--stats', self.repository_location + '::test', '-e', 'input/file2') + self.check_cache() + self.assert_in('Archive name: test', output) + self.assert_in('This archive:', output) + self.assert_in('All archives:', output) + # Without --stats, no statistics are shown. + output = self.cmd('recreate', self.repository_location + '::test', '-e', 'input/file1') + self.check_cache() + self.assert_not_in('This archive:', output) + def test_bad_filters(self): self.cmd('init', '--encryption=repokey', self.repository_location) self.cmd('create', self.repository_location + '::test', 'input')