Last active
March 23, 2026 13:39
-
-
Save owenthewizard/6b1eb30ce630370b5e14aa814dec396f to your computer and use it in GitHub Desktop.
zfs-auto-snapshot-CoryAlbrecht
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- zfs-auto-snapshot-upstream-1.2.4/Makefile | |
| +++ zfs-auto-snapshot-upstream-1.2.4-alpine/Makefile | |
| @@ -3,16 +3,16 @@ | |
| all: | |
| install: | |
| - install -d $(DESTDIR)/etc/cron.d | |
| - install -d $(DESTDIR)/etc/cron.daily | |
| - install -d $(DESTDIR)/etc/cron.hourly | |
| - install -d $(DESTDIR)/etc/cron.weekly | |
| - install -d $(DESTDIR)/etc/cron.monthly | |
| - install -m 0644 etc/zfs-auto-snapshot.cron.frequent $(DESTDIR)/etc/cron.d/zfs-auto-snapshot | |
| - install etc/zfs-auto-snapshot.cron.hourly $(DESTDIR)/etc/cron.hourly/zfs-auto-snapshot | |
| - install etc/zfs-auto-snapshot.cron.daily $(DESTDIR)/etc/cron.daily/zfs-auto-snapshot | |
| - install etc/zfs-auto-snapshot.cron.weekly $(DESTDIR)/etc/cron.weekly/zfs-auto-snapshot | |
| - install etc/zfs-auto-snapshot.cron.monthly $(DESTDIR)/etc/cron.monthly/zfs-auto-snapshot | |
| + install -d $(DESTDIR)/etc/periodic/15min | |
| + install -d $(DESTDIR)/etc/periodic/daily | |
| + install -d $(DESTDIR)/etc/periodic/hourly | |
| + install -d $(DESTDIR)/etc/periodic/weekly | |
| + install -d $(DESTDIR)/etc/periodic/monthly | |
| + install -m 0755 etc/zfs-auto-snapshot.cron.frequent $(DESTDIR)/etc/periodic/15min/zfs-auto-snapshot | |
| + install etc/zfs-auto-snapshot.cron.hourly $(DESTDIR)/etc/periodic/hourly/zfs-auto-snapshot | |
| + install etc/zfs-auto-snapshot.cron.daily $(DESTDIR)/etc/periodic/daily/zfs-auto-snapshot | |
| + install etc/zfs-auto-snapshot.cron.weekly $(DESTDIR)/etc/periodic/weekly/zfs-auto-snapshot | |
| + install etc/zfs-auto-snapshot.cron.monthly $(DESTDIR)/etc/periodic/monthly/zfs-auto-snapshot | |
| install -d $(DESTDIR)$(PREFIX)/share/man/man8 | |
| install src/zfs-auto-snapshot.8 $(DESTDIR)$(PREFIX)/share/man/man8/zfs-auto-snapshot.8 | |
| install -d $(DESTDIR)$(PREFIX)/sbin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Contributor: Henrik Riomar <[email protected]> | |
| # Maintainer: Henrik Riomar <[email protected]> | |
| pkgname=zfs-auto-snapshot | |
| pkgver=1.2.5 | |
| pkgrel=1 | |
| pkgdesc="ZFS Automatic Snapshot Service for Linux" | |
| url="https://github.com/zfsonlinux/zfs-auto-snapshot" | |
| arch="noarch !armhf !armv7" # limited by zfs | |
| license="GPL-2.0-or-later" | |
| depends="zfs" | |
| checkdepends="checkbashisms" | |
| subpackages="$pkgname-doc" | |
| source="$pkgname-v$pkgver.tar.gz::https://github.com/CoryAlbrecht/zfs-auto-snapshot/archive/release/v$pkgver.tar.gz | |
| 0001-alpine.patch | |
| whitespace-splitting-fix.patch | |
| changed.patch | |
| " | |
| builddir="$srcdir/$pkgname-release-v$pkgver" | |
| check() { | |
| checkbashisms src/zfs-auto-snapshot.sh | |
| } | |
| package() { | |
| make install PREFIX="/usr" DESTDIR="$pkgdir" | |
| } | |
| sha512sums=" | |
| 6c226cc1862e003dc2cddde5ef554e864fa29dc84c952f598452783bee9ebe46eddf64416be237be23900bb7ae570bd7f4018445ba792194cd698a5b3cb2d17e zfs-auto-snapshot-v1.2.5.tar.gz | |
| 0d897ce244723ad1df83d18ec268d405cad1bef991550d0058dfe926308ddc5df589c9bcd197552aad8dea7269d7a7087c2ae17c6ad4eafccc78e803c7879cc4 0001-alpine.patch | |
| ee5a2fb2b5c5d72988b17a1531951d6ee6683daa8e62ea4ecd1617ce587e16ae938561def8078c9b694c61c5e12f3664cbba17f7c346eb842fc51335f678b19d whitespace-splitting-fix.patch | |
| 207850a1430c2bb9414d4562834bd6f9177ead2ea80185cac9ec2057e6e567e234a1ab462c508e661f496989af1f074ba03e06331f22ed1dd9863f21dc16abf4 changed.patch | |
| " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -ur a/etc/zfs-auto-snapshot.cron.daily b/etc/zfs-auto-snapshot.cron.daily | |
| --- a/etc/zfs-auto-snapshot.cron.daily 2025-07-03 16:50:29.000000000 -0500 | |
| +++ b/etc/zfs-auto-snapshot.cron.daily 2026-02-17 01:53:24.880609086 -0600 | |
| @@ -2,4 +2,4 @@ | |
| # Only call zfs-auto-snapshot if it's available | |
| which zfs-auto-snapshot > /dev/null || exit 0 | |
| -zfs-auto-snapshot --default-exclude --quiet --syslog --label=daily --keep=31 // | |
| +zfs-auto-snapshot --default-exclude --quiet --syslog --label=daily --keep=31 --changed // | |
| diff -ur a/etc/zfs-auto-snapshot.cron.hourly b/etc/zfs-auto-snapshot.cron.hourly | |
| --- a/etc/zfs-auto-snapshot.cron.hourly 2025-07-03 16:50:29.000000000 -0500 | |
| +++ b/etc/zfs-auto-snapshot.cron.hourly 2026-02-17 01:54:08.514867415 -0600 | |
| @@ -2,4 +2,4 @@ | |
| # Only call zfs-auto-snapshot if it's available | |
| which zfs-auto-snapshot > /dev/null || exit 0 | |
| -zfs-auto-snapshot --default-exclude --quiet --syslog --label=hourly --keep=24 // | |
| \ No newline at end of file | |
| +zfs-auto-snapshot --default-exclude --quiet --syslog --label=hourly --keep=24 --changed // | |
| diff -ur a/etc/zfs-auto-snapshot.cron.monthly b/etc/zfs-auto-snapshot.cron.monthly | |
| --- a/etc/zfs-auto-snapshot.cron.monthly 2025-07-03 16:50:29.000000000 -0500 | |
| +++ b/etc/zfs-auto-snapshot.cron.monthly 2026-02-17 01:54:15.899249607 -0600 | |
| @@ -2,4 +2,4 @@ | |
| # Only call zfs-auto-snapshot if it's available | |
| which zfs-auto-snapshot > /dev/null || exit 0 | |
| -zfs-auto-snapshot --default-exclude --quiet --syslog --label=monthly --keep=12 // | |
| +zfs-auto-snapshot --default-exclude --quiet --syslog --label=monthly --keep=12 --changed // | |
| diff -ur a/etc/zfs-auto-snapshot.cron.weekly b/etc/zfs-auto-snapshot.cron.weekly | |
| --- a/etc/zfs-auto-snapshot.cron.weekly 2025-07-03 16:50:29.000000000 -0500 | |
| +++ b/etc/zfs-auto-snapshot.cron.weekly 2026-02-17 01:54:21.549542049 -0600 | |
| @@ -2,4 +2,4 @@ | |
| # Only call zfs-auto-snapshot if it's available | |
| which zfs-auto-snapshot > /dev/null || exit 0 | |
| -zfs-auto-snapshot --default-exclude --quiet --syslog --label=weekly --keep=8 // | |
| +zfs-auto-snapshot --default-exclude --quiet --syslog --label=weekly --keep=8 --changed // | |
| diff -ur a/etc/zfs-auto-snapshot.cron.frequent b/etc/zfs-auto-snapshot.cron.frequent | |
| --- a/etc/zfs-auto-snapshot.cron.frequent 2026-02-17 02:17:31.454459001 -0600 | |
| +++ b/etc/zfs-auto-snapshot.cron.frequent 2026-02-17 02:15:18.399405304 -0600 | |
| @@ -1,3 +1,5 @@ | |
| -PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin" | |
| +#!/bin/sh | |
| -*/15 * * * * root which zfs-auto-snapshot > /dev/null || exit 0 ; zfs-auto-snapshot --default-exclude --quiet --syslog --label=frequent --keep=4 // | |
| +# Only call zfs-auto-snapshot if it's available | |
| +which zfs-auto-snapshot > /dev/null || exit 0 | |
| +exec zfs-auto-snapshot --default-exclude --quiet --syslog --label=frequent --keep=4 --changed // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Maintainer: Cody Schafer <[email protected]> | |
| # Maintainer: Mike Swanson <[email protected]> | |
| pkgname=zfs-auto-snapshot | |
| pkgdesc="Implementation of a snapshotting service for ZFS" | |
| pkgver=1.2.5 | |
| pkgrel=1 | |
| arch=('any') | |
| url="https://github.com/CoryAlbrecht/zfs-auto-snapshot" | |
| license=('GPL2') | |
| depends=('systemd>=212' 'zfs') | |
| source=("$url/archive/release/v$pkgver.tar.gz" "whitespace-splitting-fix.patch") | |
| sha512sums=('6c226cc1862e003dc2cddde5ef554e864fa29dc84c952f598452783bee9ebe46eddf64416be237be23900bb7ae570bd7f4018445ba792194cd698a5b3cb2d17e' | |
| 'f31f482f1def92f46b46e61e66685f50d0b789b2e5df65264b56a875c10f6c95d8e3bb0a20f2acf51fa6f394c2409f9fd94f6506ab9c53c3b90ed57ef6c76403') | |
| prepare() { | |
| cd "$pkgname-release-v$pkgver" | |
| for patch in ../*.patch; do | |
| if [ ! -f "$patch" ]; then | |
| break; | |
| else | |
| patch -p1 -i "$patch" | |
| fi | |
| done | |
| mkdir -p "../systemd" | |
| cd "../systemd" | |
| ### "Label|NumberOfKeptSnapshots|systemd-timer-spec" of snapshots, | |
| ### eg. timer and service files, being created adjust/extend if required | |
| declare -a arr=( | |
| "frequent|4|*:0/15" | |
| "hourly|24|hourly" | |
| "daily|31|daily" | |
| "weekly|8|weekly" | |
| "monthly|12|monthly") | |
| for i in "${arr[@]}" | |
| do | |
| _label="$(echo $i | cut -d'|' -f1)" | |
| _keep="$(echo $i | cut -d'|' -f2)" | |
| _OnCalendarSpec="$(echo $i | cut -d'|' -f3)" | |
| _prefix="--prefix=znap" | |
| cat > zfs-auto-snapshot-${_label}.service <<EOF | |
| [Unit] | |
| Description=ZFS $_label snapshot service | |
| [Service] | |
| ExecStart=$_PREFIX/bin/zfs-auto-snapshot --skip-scrub $_prefix --label=$_label --keep=$_keep --changed // | |
| EOF | |
| # write timer files | |
| cat > zfs-auto-snapshot-${_label}.timer <<EOF | |
| # See systemd.timers and systemd.time manpages for details | |
| [Unit] | |
| Description=ZFS $_label snapshot timer | |
| [Timer] | |
| OnCalendar=$_OnCalendarSpec | |
| Persistent=true | |
| [Install] | |
| WantedBy=timers.target | |
| EOF | |
| done | |
| } | |
| package() { | |
| cd "$pkgname-release-v$pkgver" | |
| install -d "$pkgdir/usr/bin" | |
| install -d "$pkgdir/usr/lib/systemd/system" | |
| install -d "$pkgdir/usr/share/man/man8" | |
| install -m 755 src/zfs-auto-snapshot.sh "$pkgdir/usr/bin/zfs-auto-snapshot" | |
| install -m 644 src/zfs-auto-snapshot.8 "$pkgdir/usr/share/man/man8" | |
| install -m 644 ../systemd/* "$pkgdir/usr/lib/systemd/system" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- a/src/zfs-auto-snapshot.sh 2026-02-16 14:08:08.583544542 -0600 | |
| +++ b/src/zfs-auto-snapshot.sh 2026-02-16 14:17:47.981012208 -0600 | |
| @@ -255,7 +255,7 @@ | |
| --longoptions=debug,help,quiet,syslog,verbose \ | |
| --longoptions=pre-snapshot:,post-snapshot:,destroy-only \ | |
| --longoptions=min-size: \ | |
| - --longoptions=changed: \ | |
| + --longoptions=changed \ | |
| --options=dnshe:l:Lk:p:rs:qgcvm: \ | |
| -- "$@" ) \ | |
| || exit 128 | |
| @@ -394,6 +394,10 @@ | |
| shift 1 | |
| break | |
| ;; | |
| + (*) | |
| + print_log error "Unknown option or parser error near '$1'." | |
| + exit 140 | |
| + ;; | |
| esac | |
| done | |
| @@ -570,14 +574,16 @@ | |
| then | |
| # Snapshot this dataset non-recursively. | |
| print_log debug "Including $ii for regular snapshot." | |
| - TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR }$ii" # nb: \t | |
| + TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR | |
| +}$ii" | |
| continue 2 | |
| # Check whether the candidate name is a prefix of any excluded dataset name. | |
| elif [ "$jjj" != "${jjj#$iii}" ] | |
| then | |
| # Snapshot this dataset non-recursively. | |
| print_log debug "Including $ii for regular snapshot." | |
| - TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR }$ii" # nb: \t | |
| + TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR | |
| +}$ii" | |
| continue 2 | |
| fi | |
| done | |
| @@ -603,7 +609,8 @@ | |
| if [ -z "$opt_recursive" ] | |
| then | |
| print_log debug "Including $ii for regular snapshot." | |
| - TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR }$ii" # nb: \t | |
| + TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR | |
| +}$ii" | |
| else | |
| # Append this candidate to the recursive snapshot list because it additionally: | |
| # | |
| @@ -611,7 +618,8 @@ | |
| # * Is not the descendant of an already included filesystem. | |
| # | |
| print_log debug "Including $ii for recursive snapshot." | |
| - TARGETS_RECURSIVE="${TARGETS_RECURSIVE:+$TARGETS_RECURSIVE }$ii" # nb: \t | |
| + TARGETS_RECURSIVE="${TARGETS_RECURSIVE:+$TARGETS_RECURSIVE | |
| +}$ii" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment