Skip to content

Instantly share code, notes, and snippets.

@adonespitogo
Created August 2, 2023 00:00
Show Gist options
  • Save adonespitogo/b92e2c60d90988a83534f4b5abd1730d to your computer and use it in GitHub Desktop.
Save adonespitogo/b92e2c60d90988a83534f4b5abd1730d to your computer and use it in GitHub Desktop.
BTRFS snapper tool - backup your /boot directory (arch linux)
# /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
#!/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