From 2e8e5cdd980098241fbd5f6d92f05111818f574a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 18 Jan 2026 11:15:57 -0600 Subject: Add snapshot retention with automatic pruning Implements hybrid retention policy: - Always keep 20 most recent snapshots - Delete snapshots beyond #20 only if older than 180 days - Genesis snapshot is always protected Features: - zfs-snap-prune script with --dry-run, --test, --verbose modes - Comprehensive test suite (22 tests) - Runs automatically after pacman operations - Daily systemd timer for cleanup - Regenerates GRUB menu after pruning This prevents unbounded snapshot growth while preserving recent history and the genesis snapshot. --- build.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'build.sh') diff --git a/build.sh b/build.sh index cf5c086..67542ec 100755 --- a/build.sh +++ b/build.sh @@ -187,6 +187,10 @@ mkdir -p "$PROFILE_DIR/airootfs/usr/local/share/grub-zfs-snap" cp "$CUSTOM_DIR/40_zfs_snapshots" "$PROFILE_DIR/airootfs/usr/local/share/grub-zfs-snap/" cp "$CUSTOM_DIR/zz-grub-zfs-snap.hook" "$PROFILE_DIR/airootfs/usr/local/share/grub-zfs-snap/" +# Copy zfs-snap-prune for snapshot retention +info "Copying zfs-snap-prune..." +cp "$CUSTOM_DIR/zfs-snap-prune" "$PROFILE_DIR/airootfs/usr/local/bin/" + # Copy example config for unattended installs mkdir -p "$PROFILE_DIR/airootfs/root" cp "$CUSTOM_DIR/install-archzfs.conf.example" "$PROFILE_DIR/airootfs/root/" @@ -206,6 +210,9 @@ if grep -q "file_permissions=" "$PROFILE_DIR/profiledef.sh"; then sed -i '/^file_permissions=(/,/)/ { /)/ i\ ["/usr/local/bin/grub-zfs-snap"]="0:0:755" }' "$PROFILE_DIR/profiledef.sh" + sed -i '/^file_permissions=(/,/)/ { + /)/ i\ ["/usr/local/bin/zfs-snap-prune"]="0:0:755" + }' "$PROFILE_DIR/profiledef.sh" sed -i '/^file_permissions=(/,/)/ { /)/ i\ ["/etc/shadow"]="0:0:400" }' "$PROFILE_DIR/profiledef.sh" -- cgit v1.2.3