@@ -28,6 +28,7 @@ opt_backup_full=''
2828opt_backup_incremental=' '
2929opt_default_exclude=' '
3030opt_dry_run=' '
31+ opt_event=' -'
3132opt_keep=' '
3233opt_label=' '
3334opt_prefix=' zfs-auto-snap'
@@ -52,6 +53,7 @@ print_usage ()
5253 echo " Usage: $0 [options] [-l label] <'//' | name [name...]>
5354 --default-exclude Exclude objects if com.sun:auto-snapshot is unset.
5455 -d, --debug Print debugging messages.
56+ -e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
5557 -n, --dry-run Print actions without actually doing anything.
5658 -s, --skip-scrub Do not snapshot filesystems in scrubbing pools.
5759 -h, --help Print this usage message.
@@ -152,7 +154,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
152154
153155 for ii in $TARGETS
154156 do
155- if do_run " zfs snapshot $PROPERTIES $FLAGS '$ii @$NAME '"
157+ if do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
156158 then
157159 SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
158160 else
@@ -192,9 +194,9 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
192194
193195GETOPT=$( getopt \
194196 --longoptions=default-exclude,dry-run,skip-scrub,recursive \
195- --longoptions=keep:,label:,prefix:,sep: \
197+ --longoptions=event:, keep:,label:,prefix:,sep: \
196198 --longoptions=debug,help,quiet,syslog,verbose \
197- --options=dnshl :k:p:rs:qgv \
199+ --options=dnshe:l :k:p:rs:qgv \
198200 -- " $@ " ) \
199201 || exit 128
200202
213215 opt_default_exclude=' 1'
214216 shift 1
215217 ;;
218+ (-e|--event)
219+ if [ " ${# 2} " -gt ' 1024' ]
220+ then
221+ print_log error " The $1 parameter must be less than 1025 characters."
222+ exit 139
223+ elif [ " ${# 2} " -gt ' 0' ]
224+ then
225+ opt_event=" $2 "
226+ fi
227+ shift 2
228+ ;;
216229 (-n|--dry-run)
217230 opt_dry_run=' 1'
218231 shift 1
474487 TARGETS_RECURSIVE=" ${TARGETS_RECURSIVE: +$TARGETS_RECURSIVE } $ii " # nb: \t
475488done
476489
477-
478- # Linux lacks SMF and the notion of an FMRI event.
479- FMRI_EVENT=' -'
480-
481- # Set this property because the SUNW program does.
482- SNAPPROP=" -o com.sun:auto-snapshot-desc='$FMRI_EVENT '"
490+ # Linux lacks SMF and the notion of an FMRI event, but always set this property
491+ # because the SUNW program does. The dash character is the default.
492+ SNAPPROP=" -o com.sun:auto-snapshot-desc='$opt_event '"
483493
484494# ISO style date; fifteen characters: YYYY-MM-DD-HHMM
485495# On Solaris %H%M expands to 12h34.
0 commit comments