From 3e21cdb5796bfad45a9bb0c3e85ac1b51d6ca094 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 19 Mar 2025 19:43:04 -0700 Subject: [PATCH] Add "stats" option to configuration (#303). --- borgmatic/actions/create.py | 2 +- borgmatic/borg/prune.py | 5 +++-- borgmatic/config/schema.yaml | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/borgmatic/actions/create.py b/borgmatic/actions/create.py index c12bf43e..47e915e5 100644 --- a/borgmatic/actions/create.py +++ b/borgmatic/actions/create.py @@ -328,7 +328,7 @@ def run_create( local_path=local_path, remote_path=remote_path, progress=create_arguments.progress or config.get('progress'), - stats=create_arguments.stats, + stats=create_arguments.stats or config.get('stats'), json=create_arguments.json, list_files=create_arguments.list_files, stream_processes=stream_processes, diff --git a/borgmatic/borg/prune.py b/borgmatic/borg/prune.py index 82a78201..38d0ed67 100644 --- a/borgmatic/borg/prune.py +++ b/borgmatic/borg/prune.py @@ -66,6 +66,7 @@ def prune_archives( borgmatic.logger.add_custom_log_levels() umask = config.get('umask', None) lock_wait = config.get('lock_wait', None) + stats = prune_arguments.stats or config.get('stats') extra_borg_options = config.get('extra_borg_options', {}).get('prune', '') full_command = ( @@ -77,7 +78,7 @@ def prune_archives( + (('--lock-wait', str(lock_wait)) if lock_wait else ()) + ( ('--stats',) - if prune_arguments.stats + if stats and not dry_run and not feature.available(feature.Feature.NO_PRUNE_STATS, local_borg_version) else () @@ -94,7 +95,7 @@ def prune_archives( + flags.make_repository_flags(repository_path, local_borg_version) ) - if prune_arguments.stats or prune_arguments.list_archives: + if stats or prune_arguments.list_archives: output_log_level = logging.ANSWER else: output_log_level = logging.INFO diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 481b9e78..ab0ae1a3 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -816,6 +816,13 @@ properties: false. default: false example: true + stats: + type: boolean + description: | + Display statistics of an archive when running supported actions. + Defaults to false. + default: false + example: true skip_actions: type: array items: