From b0e49ebce01e0ba8b6e40ddb514eb6aa22b694f7 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 16 Apr 2024 10:38:14 -0700 Subject: [PATCH] When "--match-archives *" is used with "check" action, don't skip Borg's orphaned objects check (#779). --- NEWS | 2 ++ borgmatic/borg/flags.py | 3 +++ tests/unit/borg/test_flags.py | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/NEWS b/NEWS index d84b388..bc0f2c2 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ catch problems like incorrect excludes, inadvertent deletes, files changed by malware, etc. See the documentation for more information: https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/#spot-check + * #779: When "--match-archives *" is used with "check" action, don't skip Borg's orphaned objects + check. * #842: When a command hook exits with a soft failure, ping the log and finish states for any configured monitoring hooks. * #843: Add documentation link to Loki dashboard for borgmatic: diff --git a/borgmatic/borg/flags.py b/borgmatic/borg/flags.py index c06bcc9..e6e2797 100644 --- a/borgmatic/borg/flags.py +++ b/borgmatic/borg/flags.py @@ -74,6 +74,9 @@ def make_match_archives_flags(match_archives, archive_name_format, local_borg_ve (like "{now}") with globs. ''' if match_archives: + if match_archives in {'*', 're:.*', 'sh:*'}: + return () + if feature.available(feature.Feature.MATCH_ARCHIVES, local_borg_version): return ('--match-archives', match_archives) else: diff --git a/tests/unit/borg/test_flags.py b/tests/unit/borg/test_flags.py index dde9f7a..a955148 100644 --- a/tests/unit/borg/test_flags.py +++ b/tests/unit/borg/test_flags.py @@ -151,6 +151,30 @@ def test_make_repository_archive_flags_with_borg_features_joins_repository_and_a False, ('--glob-archives', '*-docs-{user}'), # noqa: FS003 ), + ( + '*', + '{now}', # noqa: FS003 + True, + (), + ), + ( + '*', + '{now}', # noqa: FS003 + False, + (), + ), + ( + 're:.*', + '{now}', # noqa: FS003 + True, + (), + ), + ( + 'sh:*', + '{now}', # noqa: FS003 + True, + (), + ), ), ) def test_make_match_archives_flags_makes_flags_with_globs(