فهرست منبع

Always error and exit when the borgmatic runtime directory overlaps with the configured excludes (#1122).

Dan Helfman 1 هفته پیش
والد
کامیت
947dc77a50
2فایلهای تغییر یافته به همراه18 افزوده شده و 11 حذف شده
  1. 2 0
      NEWS
  2. 16 11
      borgmatic/borg/create.py

+ 2 - 0
NEWS

@@ -2,6 +2,8 @@
  * #1114: Document systemd configuration changes for the ZFS filesystem hook.
  * #1118: Fix a bug in which Borg hangs during database backup when different filesystems are in
    use.
+ * #1122: To prevent the user from inadvertently excluding the "bootstrap" action's manifest, always
+   error and exit when the borgmatic runtime directory overlaps with the configured excludes.
  * #1125: Clarify documentation about ZFS, Btrfs, and LVM snapshotting when a separate
    filesystem is mounted in the source directory. (Spoiler: The separate filesystem doesn't get
    included in the snapshot.)

+ 16 - 11
borgmatic/borg/create.py

@@ -45,7 +45,7 @@ def any_parent_directories(path, candidate_parents):
     return False
 
 
-def collect_special_file_paths(
+def check_planned_backup_paths(
     dry_run,
     create_command,
     config,
@@ -111,7 +111,6 @@ def collect_special_file_paths(
     return tuple(
         path
         for path in paths
-        if special_file(path, working_directory)
         if path not in paths_containing_runtime_directory
     )
 
@@ -228,6 +227,17 @@ def make_base_create_command(
         archive_name_format,
         local_borg_version,
     )
+    working_directory = borgmatic.config.paths.get_working_directory(config)
+
+    logger.debug('Checking file paths Borg plans to backup')
+    planned_backup_paths = check_planned_backup_paths(
+        dry_run,
+        create_flags + create_positional_arguments,
+        config,
+        local_path,
+        working_directory,
+        borgmatic_runtime_directory=borgmatic_runtime_directory,
+    )
 
     # If database hooks are enabled (as indicated by streaming processes), exclude files that might
     # cause Borg to hang. But skip this if the user has explicitly set the "read_special" to True.
@@ -235,16 +245,11 @@ def make_base_create_command(
         logger.warning(
             'Ignoring configured "read_special" value of false, as true is needed for database hooks.',
         )
-        working_directory = borgmatic.config.paths.get_working_directory(config)
 
-        logger.debug('Collecting special file paths')
-        special_file_paths = collect_special_file_paths(
-            dry_run,
-            create_flags + create_positional_arguments,
-            config,
-            local_path,
-            working_directory,
-            borgmatic_runtime_directory=borgmatic_runtime_directory,
+        special_file_paths = tuple(
+            path
+            for path in planned_backup_paths
+            if special_file(path, working_directory)
         )
 
         if special_file_paths: