summarylogtreecommitdiffstats
path: root/prefix_label_order.patch
blob: dc3598afd571c5fccbffb37434ebc9eb399e8685 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/src/zfs-auto-snapshot.sh b/src/zfs-auto-snapshot.sh
index 5ef5bae..75ba11d 100755
--- a/src/zfs-auto-snapshot.sh
+++ b/src/zfs-auto-snapshot.sh
@@ -375,9 +375,7 @@ if [ -n "$opt_fast_zfs_list" ]
 then
 	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) )}') \
+		sort -t'@' -k2r,2 -k1,1) \
 	  || { print_log error "zfs list $?: $SNAPSHOTS_OLD"; exit 137; }
 else
 	SNAPSHOTS_OLD=$(env LC_ALL=C zfs list -H -t snapshot -S creation -o name) \
@@ -537,10 +535,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}_$DATE${opt_label:+$opt_sep$opt_label}"
 
 # The expression for matching old snapshots.  -YYYY-MM-DD-HHMM
-SNAPGLOB="$opt_prefix${opt_label:+?$opt_label}????????????????"
+SNAPGLOB="${opt_prefix}????????????????${opt_label:+?$opt_label}"
 
 if [ -n "$opt_do_snapshots" ]
 then