Created
June 13, 2021 10:30
-
-
Save shello/64c5e35d83b99f67833404d8496d5050 to your computer and use it in GitHub Desktop.
Pacman hook: Take a snapshot of the root dataset before any operation
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 Root Snapshot Pacman Hook | |
# 2021 Filipe Rodrigues<[email protected]> | |
# | |
# Take a snapshot of the root dataset before any pacman operation. | |
# See: https://man.archlinux.org/man/alpm-hooks.5 | |
# Depends on: pacman, zfs, coreutils | |
# Location: /etc/pacman.d/hooks/zfs_snapshot.hook | |
[Trigger] | |
Operation = Install | |
Operation = Upgrade | |
Operation = Remove | |
Type = Package | |
Target = * | |
[Action] | |
Description = Taking a snapshot of root dataset | |
When = PreTransaction | |
Exec = /bin/sh -c '/usr/bin/zfs snapshot "$(/usr/bin/zfs list -Ho name /)"@"auto-pacman-$(/usr/bin/date +%F_%T_%Z)"' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment