Skip to content

Commit 6e32b25

Browse files
committed
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.
1 parent d5cb31a commit 6e32b25

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,10 @@ SNAPPROP="-o com.sun:auto-snapshot-desc='$opt_event'"
533533
DATE=$(date --utc +%F-%H%M)
534534

535535
# The snapshot name after the @ symbol.
536-
SNAPNAME="$opt_prefix${opt_label:+$opt_sep$opt_label}-$DATE"
536+
SNAPNAME="${opt_prefix:+$opt_prefix$opt_sep}${opt_label:+$opt_label}-$DATE"
537537

538538
# The expression for matching old snapshots. -YYYY-MM-DD-HHMM
539-
SNAPGLOB="$opt_prefix${opt_label:+?$opt_label}????????????????"
539+
SNAPGLOB="${opt_prefix:+$opt_prefix$opt_sep}${opt_label:+$opt_label}-???????????????"
540540

541541
if [ -n "$opt_do_snapshots" ]
542542
then

0 commit comments

Comments
 (0)