Browse Source

Remove ZFS "enabled" option and fix override command options.

Dan Helfman 7 months ago
parent
commit
d0c90389fb
3 changed files with 7 additions and 16 deletions
  1. 1 9
      borgmatic/config/schema.yaml
  2. 2 2
      borgmatic/hooks/dispatch.py
  3. 4 5
      borgmatic/hooks/zfs.py

+ 1 - 9
borgmatic/config/schema.yaml

@@ -2261,17 +2261,9 @@ properties:
             monitoring documentation for details.
             monitoring documentation for details.
 
 
     zfs:
     zfs:
-        type: object
-        required: ['enabled']
+        type: ["object", "null"]
         additionalProperties: false
         additionalProperties: false
         properties:
         properties:
-            enabled:
-                type: boolean
-                description: |
-                    Whether to auto-detect and snapshot any ZFS dataset mount
-                    points listed in "source_directories" when creating backups.
-                    Defaults to false.
-                example: true
             zfs_command:
             zfs_command:
                 type: string
                 type: string
                 description: |
                 description: |

+ 2 - 2
borgmatic/hooks/dispatch.py

@@ -51,7 +51,7 @@ def call_hook(function_name, config, log_prefix, hook_name, *args, **kwargs):
     Raise AttributeError if the function name is not found in the module.
     Raise AttributeError if the function name is not found in the module.
     Raise anything else that the called function raises.
     Raise anything else that the called function raises.
     '''
     '''
-    hook_config = config.get(hook_name, {})
+    hook_config = config.get(hook_name) or {}
 
 
     try:
     try:
         module = HOOK_NAME_TO_MODULE[hook_name]
         module = HOOK_NAME_TO_MODULE[hook_name]
@@ -79,7 +79,7 @@ def call_hooks(function_name, config, log_prefix, hook_names, *args, **kwargs):
     return {
     return {
         hook_name: call_hook(function_name, config, log_prefix, hook_name, *args, **kwargs)
         hook_name: call_hook(function_name, config, log_prefix, hook_name, *args, **kwargs)
         for hook_name in hook_names
         for hook_name in hook_names
-        if config.get(hook_name)
+        if hook_name in config
     }
     }
 
 
 
 

+ 4 - 5
borgmatic/hooks/zfs.py

@@ -47,7 +47,7 @@ def dump_data_sources(
     # TODO: Dry run.
     # TODO: Dry run.
 
 
     # List ZFS datasets to get their mount points.
     # List ZFS datasets to get their mount points.
-    zfs_command = config.get('zfs_command', 'zfs')
+    zfs_command = hook_config.get('zfs_command', 'zfs')
     list_command = (
     list_command = (
         zfs_command,
         zfs_command,
         'list',
         'list',
@@ -105,10 +105,9 @@ def dump_data_sources(
         logger.debug(f'{log_prefix}: Mounting ZFS snapshot {full_snapshot_name} at {snapshot_path}')
         logger.debug(f'{log_prefix}: Mounting ZFS snapshot {full_snapshot_name} at {snapshot_path}')
 
 
         os.makedirs(snapshot_path, mode=0o700, exist_ok=True)
         os.makedirs(snapshot_path, mode=0o700, exist_ok=True)
-
         borgmatic.execute.execute_command(
         borgmatic.execute.execute_command(
             (
             (
-                config.get('mount_command', 'mount'),
+                hook_config.get('mount_command', 'mount'),
                 '-t',
                 '-t',
                 'zfs',
                 'zfs',
                 f'{dataset_name}@{snapshot_name}',
                 f'{dataset_name}@{snapshot_name}',
@@ -133,7 +132,7 @@ def remove_data_source_dumps(hook_config, config, log_prefix, borgmatic_runtime_
     # TODO: Dry run.
     # TODO: Dry run.
 
 
     # Unmount snapshots.
     # Unmount snapshots.
-    zfs_command = config.get('zfs_command', 'zfs')
+    zfs_command = hook_config.get('zfs_command', 'zfs')
     list_datasets_command = (
     list_datasets_command = (
         zfs_command,
         zfs_command,
         'list',
         'list',
@@ -171,7 +170,7 @@ def remove_data_source_dumps(hook_config, config, log_prefix, borgmatic_runtime_
             logger.debug(f'{log_prefix}: Unmounting ZFS snapshot at {snapshot_path}')
             logger.debug(f'{log_prefix}: Unmounting ZFS snapshot at {snapshot_path}')
             borgmatic.execute.execute_command(
             borgmatic.execute.execute_command(
                 (
                 (
-                    config.get('umount_command', 'umount'),
+                    hook_config.get('umount_command', 'umount'),
                     snapshot_path,
                     snapshot_path,
                 ),
                 ),
                 output_log_level=logging.DEBUG,
                 output_log_level=logging.DEBUG,