refactor(script): Don't use zfs-auto-snapshot, but add jq (#1)

This commit is contained in:
hygienic-books 2023-03-06 00:12:50 +01:00
parent 1e56f28dc8
commit 6a666c5c8e
4 changed files with 5 additions and 6 deletions

View File

@ -6,7 +6,7 @@ Arch Linux pacman hook for automatic ZFS snapshots
Get started like so: Get started like so:
1. Install dependency `zfs-auto-snapshot` 1. Install dependency `jq`
1. Clone repo into arbitrary path `<repo>` 1. Clone repo into arbitrary path `<repo>`
1. Make `pacman-zfs-snapshot.sh` executable 1. Make `pacman-zfs-snapshot.sh` executable
``` ```
@ -29,7 +29,7 @@ In `pacman` on every `PreTransaction`, meaning right before any actual operation
We retain two different snapshot chains, one for `pacman` transactions that only affect what we are calling _trivial_ packages and a separate chain for _important_ packages. By default only the exact regular expression package name match `^linux$` is considered important. Whenever an important package is affected by a transaction a snapshot goes into the corresponding chain. In all other cases - when an important package is not affected - snapshots go into the trivial chain. We retain two different snapshot chains, one for `pacman` transactions that only affect what we are calling _trivial_ packages and a separate chain for _important_ packages. By default only the exact regular expression package name match `^linux$` is considered important. Whenever an important package is affected by a transaction a snapshot goes into the corresponding chain. In all other cases - when an important package is not affected - snapshots go into the trivial chain.
We use `zfs-auto-snapshot` both for snapshot creation and for destroying old snapshots. The _trivial_ snapshot chain by default keeps 15 snapshots, the _important_ chain keeps 5. The thought process here is that you will likely not futz around with a kernel every day whereas you may very well install arbitrary packages multiple times a day. Snapshots should keep you safe for a couple of days hence the defaults of 5 and 15 snapshots, respectively. The _trivial_ snapshot chain by default keeps 15 snapshots, the _important_ chain keeps 5. The thought process here is that you will likely not futz around with a kernel every day whereas you may very well install arbitrary packages multiple times a day. Snapshots should keep you safe for a couple of days hence the defaults of 5 and 15 snapshots, respectively.
You may optionally include more ZFS datasets in this snapshot mechanism. Have a look at `pacman-zfs-snapshot.conf`, its comments should be clear enough to get you going. You may optionally include more ZFS datasets in this snapshot mechanism. Have a look at `pacman-zfs-snapshot.conf`, its comments should be clear enough to get you going.
@ -52,7 +52,6 @@ Commit _types_ besides `fix` and `feat` are:
The following _scopes_ are known for this project. A Conventional Commits commit message may optionally use one of the following scopes or none: The following _scopes_ are known for this project. A Conventional Commits commit message may optionally use one of the following scopes or none:
- `auto`: Change how `zfs-auto-snapshot` is run
- `conf`: How we deal with script config - `conf`: How we deal with script config
- `script`: Any other script work that doesn't specifically fall into the above scopes - `script`: Any other script work that doesn't specifically fall into the above scopes
- `hook`: Configuring the hook(s) - `hook`: Configuring the hook(s)

View File

@ -7,6 +7,6 @@ Target = *
Description = Create ZFS snapshot on active system dataset Description = Create ZFS snapshot on active system dataset
When = PreTransaction When = PreTransaction
Exec = /bin/sh -c 'while read -r f; do echo "$f"; done | /usr/local/bin/pacman-zfs-snapshot install' Exec = /bin/sh -c 'while read -r f; do echo "$f"; done | /usr/local/bin/pacman-zfs-snapshot install'
Depends = zfs-auto-snapshot Depends = jq
AbortOnFail AbortOnFail
NeedsTargets NeedsTargets

View File

@ -7,6 +7,6 @@ Target = *
Description = Create ZFS snapshot on active system dataset Description = Create ZFS snapshot on active system dataset
When = PreTransaction When = PreTransaction
Exec = /bin/sh -c 'while read -r f; do echo "$f"; done | /usr/local/bin/pacman-zfs-snapshot remove' Exec = /bin/sh -c 'while read -r f; do echo "$f"; done | /usr/local/bin/pacman-zfs-snapshot remove'
Depends = zfs-auto-snapshot Depends = jq
AbortOnFail AbortOnFail
NeedsTargets NeedsTargets

View File

@ -7,6 +7,6 @@ Target = *
Description = Create ZFS snapshot on active system dataset Description = Create ZFS snapshot on active system dataset
When = PreTransaction When = PreTransaction
Exec = /bin/sh -c 'while read -r f; do echo "$f"; done | /usr/local/bin/pacman-zfs-snapshot upgrade' Exec = /bin/sh -c 'while read -r f; do echo "$f"; done | /usr/local/bin/pacman-zfs-snapshot upgrade'
Depends = zfs-auto-snapshot Depends = jq
AbortOnFail AbortOnFail
NeedsTargets NeedsTargets