From 9dcdbb6da410931f7ca950794ca22755fac3e110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Zumer?= Date: Tue, 19 Mar 2024 01:37:30 -0400 Subject: [PATCH] Allow snapshot labels to be whitelisted To match the Solaris implementation, it should be possible to disable all snapshots via the com.sun:auto-snapshot property, and subsequently override that parameter by explicitly enabling individual labels. This is achieved when opt_default_exclude is disabled (the default behavior) by adding datasets for which the label is explicitly enabled to CANDIDATES. --- src/zfs-auto-snapshot.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/zfs-auto-snapshot.sh b/src/zfs-auto-snapshot.sh index cd88f0f..063c0e4 100644 --- a/src/zfs-auto-snapshot.sh +++ b/src/zfs-auto-snapshot.sh @@ -463,9 +463,11 @@ then CANDIDATES=$(echo "$ZFS_LIST" | awk -F '\t' \ 'tolower($2) ~ /true/ || tolower($3) ~ /true/ {print $1}') else - # Invert the NOAUTO list. + # Get a list of datasets for which snapshots are either not explicitly + # disabled, or explicitly enabled for the specific label. CANDIDATES=$(echo "$ZFS_LIST" | awk -F '\t' \ - 'tolower($2) !~ /false/ && tolower($3) !~ /false/ {print $1}') + '(tolower($2) !~ /false/ && tolower($3) !~ /false/) \ + || tolower($3) ~ /true/ {print $1}') fi # Initialize the list of datasets that will get a recursive snapshot.