summaryrefslogtreecommitdiff
path: root/assets/2026-01-17-zfs-sanoid-feature-request.txt
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-01-17 17:55:20 -0600
committerCraig Jennings <c@cjennings.net>2026-01-17 17:55:20 -0600
commite13933a47ed9814927f46d24ef58c969f2e4d0ac (patch)
treeb85ebbad730a5c2cf978cc73a64df46e58d0f280 /assets/2026-01-17-zfs-sanoid-feature-request.txt
parent91c8e32100b1062529451cc5466aca669f31fd6c (diff)
feat(archsetup): ZFS/sanoid support, gvfs-smb, bug fixes
- Add ZFS detection with sanoid/syncoid for snapshot management - Add gvfs-smb for Thunar SMB network browsing - Fix shell quoting throughout script - Fix stale $action variables in error handlers - Fix display() return values (was returning 1) - Fix mkinitcpio.conf sed pattern to be flexible - Fix vconsole.conf duplicate entries on re-run - Fix systemd unit overrides using drop-in files - Fix ufw port typo (55353 -> 5353) - Fix GRUB_RECORDFAIL_TIMEOUT undefined variable - Enable NetworkManager service - Move thunar, libvips, isync to pacman (now in official repos) - Clean up reflector config with heredoc - Remove unnecessary sudo when already root - Convert shebang from sh to bash
Diffstat (limited to 'assets/2026-01-17-zfs-sanoid-feature-request.txt')
-rw-r--r--assets/2026-01-17-zfs-sanoid-feature-request.txt202
1 files changed, 202 insertions, 0 deletions
diff --git a/assets/2026-01-17-zfs-sanoid-feature-request.txt b/assets/2026-01-17-zfs-sanoid-feature-request.txt
new file mode 100644
index 0000000..87207f2
--- /dev/null
+++ b/assets/2026-01-17-zfs-sanoid-feature-request.txt
@@ -0,0 +1,202 @@
+ZFS Detection and Sanoid Installation
+======================================
+
+When archsetup runs, it should detect if the system is on ZFS and install sanoid.
+
+Detection:
+- Check if root filesystem is ZFS: `findmnt -n -o FSTYPE /` returns "zfs"
+- Or check if zpool exists: `zpool list -H 2>/dev/null`
+
+If ZFS detected:
+1. Install sanoid from AUR: `yay -S sanoid`
+2. Create /etc/sanoid/sanoid.conf (see below)
+3. Enable the timer: `systemctl enable --now sanoid.timer`
+4. Create the syncoid replication script and systemd units (see below)
+
+Context:
+- install-archzfs can't install sanoid (AUR package)
+- archsetup already has AUR helper setup, so it's the right place to install it
+- syncoid (for TrueNAS replication) comes with the sanoid package
+
+Added: 2026-01-17
+
+================================================================================
+SANOID CONFIGURATION (/etc/sanoid/sanoid.conf)
+================================================================================
+
+# Sanoid configuration for ZFS snapshots
+# Less aggressive - TrueNAS handles long-term backups
+
+#############################
+# Templates
+#############################
+
+[template_production]
+ # Local rollback capability
+ hourly = 6
+ daily = 7
+ weekly = 2
+ monthly = 1
+ autosnap = yes
+ autoprune = yes
+
+[template_backup]
+ # Less frequent for large/static data
+ hourly = 0
+ daily = 3
+ weekly = 2
+ monthly = 1
+ autosnap = yes
+ autoprune = yes
+
+[template_none]
+ autosnap = no
+ autoprune = yes
+
+#############################
+# Datasets
+#############################
+
+[zroot/ROOT/default]
+ use_template = production
+
+[zroot/home]
+ use_template = production
+ recursive = yes
+
+[zroot/media]
+ use_template = backup
+
+[zroot/vms]
+ use_template = backup
+
+[zroot/var/log]
+ use_template = production
+
+[zroot/var/lib/pacman]
+ use_template = production
+
+[zroot/var/cache]
+ use_template = none
+
+[zroot/var/tmp]
+ use_template = none
+
+[zroot/tmp]
+ use_template = none
+
+================================================================================
+SYNCOID REPLICATION SCRIPT (/usr/local/bin/zfs-replicate)
+================================================================================
+
+#!/bin/bash
+# zfs-replicate - Replicate ZFS datasets to TrueNAS
+#
+# Usage:
+# zfs-replicate # Replicate all configured datasets
+# zfs-replicate [dataset] # Replicate specific dataset
+
+set -e
+
+# TrueNAS Configuration
+# Try local network first, fall back to tailscale
+TRUENAS_LOCAL="truenas.local"
+TRUENAS_TAILSCALE="truenas"
+TRUENAS_USER="root"
+TRUENAS_POOL="vault"
+BACKUP_PATH="backups" # TODO: Configure actual path
+
+# Datasets to replicate
+DATASETS="zroot/ROOT/default zroot/home zroot/media zroot/vms"
+
+# Colors
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+RED='\033[0;31m'
+NC='\033[0m'
+
+info() { echo -e "${GREEN}[INFO]${NC} $1"; }
+warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
+error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
+
+command -v syncoid >/dev/null 2>&1 || error "syncoid not found. Install sanoid package."
+
+# Determine which host to use
+determine_host() {
+ if ping -c 1 -W 2 "$TRUENAS_LOCAL" &>/dev/null; then
+ echo "$TRUENAS_LOCAL"
+ elif ping -c 1 -W 2 "$TRUENAS_TAILSCALE" &>/dev/null; then
+ echo "$TRUENAS_TAILSCALE"
+ else
+ error "Cannot reach TrueNAS at $TRUENAS_LOCAL or $TRUENAS_TAILSCALE"
+ fi
+}
+
+TRUENAS_HOST=$(determine_host)
+info "Using TrueNAS host: $TRUENAS_HOST"
+
+# Single dataset mode
+if [[ -n "$1" ]]; then
+ dataset="$1"
+ dest="$TRUENAS_USER@$TRUENAS_HOST:$TRUENAS_POOL/$BACKUP_PATH/${dataset#zroot/}"
+ info "Replicating $dataset -> $dest"
+ syncoid --recursive "$dataset" "$dest"
+ exit 0
+fi
+
+# Full replication
+info "Starting ZFS replication to $TRUENAS_HOST"
+echo ""
+
+for dataset in $DATASETS; do
+ dest="$TRUENAS_USER@$TRUENAS_HOST:$TRUENAS_POOL/$BACKUP_PATH/${dataset#zroot/}"
+ info "Replicating $dataset -> $dest"
+
+ if syncoid --recursive "$dataset" "$dest"; then
+ info " Success"
+ else
+ warn " Failed (will retry next run)"
+ fi
+ echo ""
+done
+
+info "Replication complete."
+
+================================================================================
+SYSTEMD SERVICE (/etc/systemd/system/zfs-replicate.service)
+================================================================================
+
+[Unit]
+Description=ZFS Replication to TrueNAS
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/local/bin/zfs-replicate
+User=root
+
+[Install]
+WantedBy=multi-user.target
+
+================================================================================
+SYSTEMD TIMER (/etc/systemd/system/zfs-replicate.timer)
+================================================================================
+
+[Unit]
+Description=Run ZFS replication nightly
+
+[Timer]
+OnCalendar=*-*-* 02:00:00
+RandomizedDelaySec=1800
+Persistent=true
+
+[Install]
+WantedBy=timers.target
+
+================================================================================
+ENABLE REPLICATION
+================================================================================
+
+After SSH key auth is set up to TrueNAS:
+ systemctl enable --now zfs-replicate.timer