From 6e32b25d8f5dc70c850cf78a6f6a5e0d8f3de925 Mon Sep 17 00:00:00 2001 From: Turbo Fredriksson Date: Fri, 3 Apr 2015 02:12:16 +0200 Subject: [PATCH] Fix SNAPNAME and SNAPGLOB. * Currently the following command line: zfs-auto-snapshot.sh.orig --keep 7 --label daily --prefix '' --sep '-' \ --event "daily-$(date --utc +"%Y%m%d.%H%M")" --recursive --verbose // will give the following result: zfs snapshot -o com.sun:auto-snapshot-desc='daily-20150403.0013' \ -r 'share/.Bacula@-daily-2015-04-03-0013' * If instead 'prefix=daily', this would be the result: zfs snapshot -o com.sun:auto-snapshot-desc='daily-20150403.0015' \ -r 'share/.Bacula@daily-daily-2015-04-03-0016' * If 'prefix=daily' and 'label=NULL': zfs snapshot -o com.sun:auto-snapshot-desc='daily-20150403.0017' \ -r 'share@daily' This because SNAPNAME is constructed wrongly. Instead, only separate the 'prefix' from the 'label' with 'sep' if 'prefix' is actually set. --- src/zfs-auto-snapshot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zfs-auto-snapshot.sh b/src/zfs-auto-snapshot.sh index 2a82c9a..23a8190 100755 --- a/src/zfs-auto-snapshot.sh +++ b/src/zfs-auto-snapshot.sh @@ -533,10 +533,10 @@ SNAPPROP="-o com.sun:auto-snapshot-desc='$opt_event'" DATE=$(date --utc +%F-%H%M) # The snapshot name after the @ symbol. -SNAPNAME="$opt_prefix${opt_label:+$opt_sep$opt_label}-$DATE" +SNAPNAME="${opt_prefix:+$opt_prefix$opt_sep}${opt_label:+$opt_label}-$DATE" # The expression for matching old snapshots. -YYYY-MM-DD-HHMM -SNAPGLOB="$opt_prefix${opt_label:+?$opt_label}????????????????" +SNAPGLOB="${opt_prefix:+$opt_prefix$opt_sep}${opt_label:+$opt_label}-???????????????" if [ -n "$opt_do_snapshots" ] then