Package Details: zfs-auto-snapshot-git 1:1.2.4.r0.277287f-1

Git Clone URL: https://aur.archlinux.org/zfs-auto-snapshot-git.git (read-only)
Package Base: zfs-auto-snapshot-git
Description: Implementation of a snapshotting service for ZFS
Upstream URL: https://github.com/zfsonlinux/zfs-auto-snapshot
Licenses: GPL2
Conflicts: zfs-auto-snapshot
Provides: zfs-auto-snapshot
Submitter: chungy
Maintainer: chungy
Last Packager: chungy
Votes: 7
Popularity: 0.046375
First Submitted: 2015-09-03 02:04
Last Updated: 2018-02-14 00:27

Latest Comments

jonathon commented on 2019-04-13 10:27

prefix_label_order.patch fails to apply after b0a5909. "Fixed" patch is below though it will need to be checked against the upstream changes to SNAPNAME and SNAPGLOB.

aurweb changes tabs to spaces (and trims trailing whitespace) so this won't work copy&paste. :( An actually-working version is here (for a week, anyway): https://bpaste.net/show/935b2a7beeba

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
@@ -398,9 +398,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) \
@@ -569,10 +569,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_prefix$opt_sep}${opt_label:+$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_prefix$opt_sep}${opt_label:+$opt_label}-???????????????"
+SNAPGLOB="${opt_prefix}????????????????${opt_label:+?$opt_label}"

 if [ -n "$opt_do_snapshots" ]
 then

jgottula commented on 2017-09-18 23:12

Oh good, it looks like my comment did post properly this time. Basically the problem is that the zfs-auto-snapshot utility itself, when in --fast mode, uses some fairly hacky substring-sorting trickery to sort the snapshots by date, and that code was written based on the implicit assumption that the last component of the snap name will be the date+time.

Here's my PKGBUILD diff that applies a patch to fix the sorting:
https://gist.github.com/anonymous/b9772d6a1c89601435a0b6e44ac0e0cc

(I've tested it with the 'PREFIX_DATE_LABEL' modification, but didn't check with the original 'PREFIX-LABEL_DATE' naming, so maybe check into that.)

jgottula commented on 2017-09-18 23:01

Hi. I've discovered that the ArchLinux-specific modification in this PKGBUILD (and also in the PKGBUILD for zfs-auto-snapshot) that changes the snapshot name format from 'PREFIX-LABEL_DATE' to 'PREFIX_DATE_LABEL', while nice, has a big problem: it breaks the sorting of old snapshots when the --fast option is used. Which means that the old-snapshot-deletion feature of the utility will end up destroying snaps that aren't actually the oldest ones! I do have a fix patch if you want it; I tried to comment here before but my comment didn't seem to show up.