From 36cd7ea16dc001f0aae109d5ce37b14df8a0680c Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Mon, 6 Mar 2023 00:39:18 +0100 Subject: [PATCH] feat(script): Introduce dry-run option (#1) --- README.md | 2 +- pacman-zfs-snapshot.conf | 2 ++ pacman-zfs-snapshot.sh | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fe96fb..2152685 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Get started like so: sudo ln -s /pacman-zfs-snapshot.conf /etc/pacman-zfs-snapshot.conf ``` Note that while you may choose arbitrary locations for symlinks the `pacman-zfs-snapshot.hook` file references `/usr/local/bin/pacman-zfs-snapshot`. Change that accordingly if you need to. -1. Adjust `pacman-zfs-snapshot.conf` to your liking +1. Adjust `pacman-zfs-snapshot.conf` to your liking. You may want to set `do_dry_run='true'` for a start and just reinstall a benign package to get a feel for what this hook would do. 1. For datasets you want auto-snapshotted add property `space.quico:auto-snapshot=true` ``` zfs set space.quico:auto-snapshot=true zpool/root/archlinux diff --git a/pacman-zfs-snapshot.conf b/pacman-zfs-snapshot.conf index 8bbb50d..104c602 100644 --- a/pacman-zfs-snapshot.conf +++ b/pacman-zfs-snapshot.conf @@ -1,3 +1,5 @@ +do_dry_run='true' + # Pipe-separated list of kernel names. Will be matched against regular # expression ^this_var_here$. Snapshots taken before a pacman transaction on # an important package have a separate retention from snapshots for trivial diff --git a/pacman-zfs-snapshot.sh b/pacman-zfs-snapshot.sh index 0b46e07..b806d2e 100755 --- a/pacman-zfs-snapshot.sh +++ b/pacman-zfs-snapshot.sh @@ -16,6 +16,7 @@ if [[ -r "${conf_file}" ]]; then source "${conf_file}" fi +if [[ ! "${do_dry_run}" ]]; then do_dry_run='true'; fi if [[ ! "${important_names}" ]]; then important_names='linux'; fi if [[ ! "${snaps_trivial_keep}" ]]; then snaps_trivial_keep='5'; fi if [[ ! "${snaps_important_keep}" ]]; then snaps_important_keep='5'; fi