24
24
"
25
25
26
26
# Set default program options.
27
+ opt_date_format=' %F-%H%M'
27
28
opt_backup_full=' '
28
29
opt_backup_incremental=' '
29
30
opt_default_exclude=' '
@@ -56,6 +57,7 @@ print_usage ()
56
57
{
57
58
echo " Usage: $0 [options] [-l label] <'//' | name [name...]>
58
59
--default-exclude Exclude datasets if com.sun:auto-snapshot is unset.
60
+ -D, --date=FORMAT Date format. Default '%F-%H%M'.
59
61
-d, --debug Print debugging messages.
60
62
-e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
61
63
--fast Use a faster zfs list invocation.
@@ -210,9 +212,9 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
210
212
GETOPT=$( getopt \
211
213
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
212
214
--longoptions=event:,keep:,label:,prefix:,sep: \
213
- --longoptions=debug,help,quiet,syslog,verbose \
215
+ --longoptions=date:, debug,help,quiet,syslog,verbose \
214
216
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
215
- --options=dnshe:l:k:p:rs:qgv \
217
+ --options=D: dnshe:l:k:p:rs:qgv \
216
218
-- " $@ " ) \
217
219
|| exit 128
218
220
@@ -221,6 +223,10 @@ eval set -- "$GETOPT"
221
223
while [ " $# " -gt ' 0' ]
222
224
do
223
225
case " $1 " in
226
+ (-D|--date)
227
+ opt_date_format=" $2 "
228
+ shift 2
229
+ ;;
224
230
(-d|--debug)
225
231
opt_debug=' 1'
226
232
opt_quiet=' '
@@ -530,7 +536,7 @@ SNAPPROP="-o com.sun:auto-snapshot-desc='$opt_event'"
530
536
531
537
# ISO style date; fifteen characters: YYYY-MM-DD-HHMM
532
538
# On Solaris %H%M expands to 12h34.
533
- DATE=$( date --utc +%F-%H%M )
539
+ DATE=$( date --utc +" $opt_date_format " )
534
540
535
541
# The snapshot name after the @ symbol.
536
542
SNAPNAME=" $opt_prefix ${opt_label: +$opt_sep$opt_label } -$DATE "
0 commit comments