Created
August 2, 2023 00:00
-
-
Save adonespitogo/b92e2c60d90988a83534f4b5abd1730d to your computer and use it in GitHub Desktop.
BTRFS snapper tool - backup your /boot directory (arch linux)
This file contains 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
# /etc/pacman.d/hooks/95-bootbackup.hook | |
[Trigger] | |
Operation = Upgrade | |
Operation = Install | |
Operation = Remove | |
Type = Path | |
Target = usr/lib/modules/*/vmlinuz | |
[Action] | |
Description = Backing up /boot... | |
When = PreTransaction | |
Exec = /usr/bin/sh /usr/local/bin/bootbackup.sh |
This file contains 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
#!/bin/sh | |
# Put it in /usr/local/bin/bootbackup.sh and make it executable. | |
BKDIR="/.bootbackup/$(uname -r)" | |
if [[ -d $BKDIR ]]; then | |
echo "Clean up $BKDIR..." | |
rm -rf $BKDIR | |
fi | |
echo "Copying /boot to $BKDIR..." | |
mkdir -p $BKDIR | |
cp -r /boot/* $BKDIR | |
echo "Creating a snapper backup for linux $(uname -r)" | |
snapper -c root create -d "Backup for linux $(uname -r)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment