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.
This commit is contained in:
Turbo Fredriksson 2015-04-03 02:12:16 +02:00
parent d5cb31aaae
commit 6e32b25d8f

View File

@ -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