From 976fb8f343429715cf3ec0a353f64277df3e7ae3 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Fri, 21 Mar 2025 22:44:49 -0700 Subject: [PATCH] Add "compact_threshold" option, overridden by "compact --threshold" flag (#303). --- borgmatic/actions/compact.py | 2 +- borgmatic/config/schema.yaml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/borgmatic/actions/compact.py b/borgmatic/actions/compact.py index 1a0cea3d..7386d230 100644 --- a/borgmatic/actions/compact.py +++ b/borgmatic/actions/compact.py @@ -39,7 +39,7 @@ def run_compact( remote_path=remote_path, progress=compact_arguments.progress or config.get('progress'), cleanup_commits=compact_arguments.cleanup_commits, - threshold=compact_arguments.threshold, + threshold=compact_arguments.threshold or config.get('compact_threshold'), ) else: # pragma: nocover logger.info('Skipping compact (only available/needed in Borg 1.2+)') diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 86cc5255..a7c9fc4c 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -565,6 +565,12 @@ properties: not specified, borgmatic defaults to matching archives based on the archive_name_format (see above). example: sourcehostname + compact_threshold: + type: integer + description: | + Minimum saved space percentage threshold for compacting a segment, + defaults to 10. + example: 20 checks: type: array items: