Browse Source

When "--match-archives *" is used with "check" action, don't skip Borg's orphaned objects check (#779).

Dan Helfman 1 year ago
parent
commit
b0e49ebce0
3 changed files with 29 additions and 0 deletions
  1. 2 0
      NEWS
  2. 3 0
      borgmatic/borg/flags.py
  3. 24 0
      tests/unit/borg/test_flags.py

+ 2 - 0
NEWS

@@ -4,6 +4,8 @@
    catch problems like incorrect excludes, inadvertent deletes, files changed by malware, etc. See
    catch problems like incorrect excludes, inadvertent deletes, files changed by malware, etc. See
    the documentation for more information:
    the documentation for more information:
    https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/#spot-check
    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
  * #842: When a command hook exits with a soft failure, ping the log and finish states for any
    configured monitoring hooks.
    configured monitoring hooks.
  * #843: Add documentation link to Loki dashboard for borgmatic:
  * #843: Add documentation link to Loki dashboard for borgmatic:

+ 3 - 0
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.
     (like "{now}") with globs.
     '''
     '''
     if match_archives:
     if match_archives:
+        if match_archives in {'*', 're:.*', 'sh:*'}:
+            return ()
+
         if feature.available(feature.Feature.MATCH_ARCHIVES, local_borg_version):
         if feature.available(feature.Feature.MATCH_ARCHIVES, local_borg_version):
             return ('--match-archives', match_archives)
             return ('--match-archives', match_archives)
         else:
         else:

+ 24 - 0
tests/unit/borg/test_flags.py

@@ -151,6 +151,30 @@ def test_make_repository_archive_flags_with_borg_features_joins_repository_and_a
             False,
             False,
             ('--glob-archives', '*-docs-{user}'),  # noqa: FS003
             ('--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(
 def test_make_match_archives_flags_makes_flags_with_globs(