@@ -29,6 +29,7 @@ opt_backup_incremental=''
2929opt_default_exclude=' '
3030opt_dry_run=' '
3131opt_event=' -'
32+ opt_fast_zfs_list=' '
3233opt_keep=' '
3334opt_label=' '
3435opt_prefix=' zfs-auto-snap'
@@ -54,6 +55,7 @@ print_usage ()
5455 --default-exclude Exclude datasets if com.sun:auto-snapshot is unset.
5556 -d, --debug Print debugging messages.
5657 -e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
58+ --fast Use a faster zfs list invocation.
5759 -n, --dry-run Print actions without actually doing anything.
5860 -s, --skip-scrub Do not snapshot filesystems in scrubbing pools.
5961 -h, --help Print this usage message.
@@ -193,7 +195,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
193195# {
194196
195197GETOPT=$( getopt \
196- --longoptions=default-exclude,dry-run,skip-scrub,recursive \
198+ --longoptions=default-exclude,dry-run,fast, skip-scrub,recursive \
197199 --longoptions=event:,keep:,label:,prefix:,sep: \
198200 --longoptions=debug,help,quiet,syslog,verbose \
199201 --options=dnshe:l:k:p:rs:qgv \
226228 fi
227229 shift 2
228230 ;;
231+ (--fast)
232+ opt_fast_zfs_list=' 1'
233+ shift 1
234+ ;;
229235 (-n|--dry-run)
230236 opt_dry_run=' 1'
231237 shift 1
@@ -339,9 +345,14 @@ ZFS_LIST=$(env LC_ALL=C zfs list -H -t filesystem,volume -s name \
339345 -o name,com.sun:auto-snapshot,com.sun:auto-snapshot:" $opt_label " ) \
340346 || { print_log error " zfs list $? : $ZFS_LIST " ; exit 136; }
341347
342- SNAPSHOTS_OLD=$( env LC_ALL=C zfs list -H -t snapshot -o name -s name| grep $opt_prefix | awk ' { print substr( $0, length($0) - 14, length($0) ) " " $0}' | sort -r -k1,1 -k2,2| awk ' { print substr( $0, 17, length($0) )}' ) \
343- || { print_log error " zfs list $? : $SNAPSHOTS_OLD " ; exit 137; }
344-
348+ if [ -n " $opt_fast_zfs_list " ]
349+ then
350+ SNAPSHOTS_OLD=$( env LC_ALL=C zfs list -H -t snapshot -o name -s name| grep $opt_prefix | awk ' { print substr( $0, length($0) - 14, length($0) ) " " $0}' | sort -r -k1,1 -k2,2| awk ' { print substr( $0, 17, length($0) )}' ) \
351+ || { print_log error " zfs list $? : $SNAPSHOTS_OLD " ; exit 137; }
352+ else
353+ SNAPSHOTS_OLD=$( env LC_ALL=C zfs list -H -t snapshot -S creation -o name) \
354+ || { print_log error " zfs list $? : $SNAPSHOTS_OLD " ; exit 137; }
355+ fi
345356
346357# Verify that each argument is a filesystem or volume.
347358for ii in " $@ "
0 commit comments