Hey all so I searched in a lot of available resources about this topic and Set up Btrfs snapshots on Fedora 42 with this and been running this for a week and everything works. Just want to check if there are any errors in my setup before I recommend it to others.
The setup:
Install packages:
sudo dnf install -y snapper libdnf5-plugin-actions btrfs-assistant inotify-tools git make
Configure snapper:
sudo snapper -c root create-config /
sudo snapper -c root set-config ALLOW_USERS=$USER SYNC_ACL=yes
sudo restorecon -RFv /.snapshots
echo 'PRUNENAMES = ".snapshots"' | sudo tee -a /etc/updatedb.conf
sudo snapper -c root set-config \
TIMELINE_CREATE=yes \
TIMELINE_CLEANUP=yes \
TIMELINE_MIN_AGE=1800 \
TIMELINE_LIMIT_HOURLY=0 \
TIMELINE_LIMIT_DAILY=3 \
TIMELINE_LIMIT_WEEKLY=1 \
TIMELINE_LIMIT_MONTHLY=1 \
TIMELINE_LIMIT_QUARTERLY=0 \
TIMELINE_LIMIT_YEARLY=0 \
NUMBER_CLEANUP=yes \
NUMBER_MIN_AGE=1800 \
NUMBER_LIMIT=8 \
NUMBER_LIMIT_IMPORTANT=4
sudo snapper -c root create --description "Initial system setup - $(date +%Y-%m-%d)"
DNF5 auto-snapshots:
sudo mkdir -p /etc/dnf/libdnf5-plugins
sudo tee /etc/dnf/libdnf5-plugins/actions.toml > /dev/null <<'EOF'
[pre_transaction]
snapper_pre = "/usr/bin/sh -c 'export tmp_snapper_pre_number=$(snapper create -t pre -c number -p -d \"System Update: $(date +\"%Y-%m-%d %H:%M:%S\")\")'"
[post_transaction]
snapper_post = "/usr/bin/sh -c 'if [ -n \"$tmp_snapper_pre_number\" ]; then snapper create -t post --pre-number \"$tmp_snapper_pre_number\" -c number -d \"System Update: $(date +\"%Y-%m-%d %H:%M:%S\")\"; fi'"
EOF
Grub-btrfs install:
git clone https://github.com/Antynea/grub-btrfs
cd grub-btrfs
sed -i.bkp \
-e '/^#GRUB_BTRFS_GRUB_DIRNAME=/a \
GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"' \
-e '/^#GRUB_BTRFS_MKCONFIG=/a \
GRUB_BTRFS_MKCONFIG=/usr/sbin/grub2-mkconfig' \
-e '/^#GRUB_BTRFS_SCRIPT_CHECK=/a \
GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check' \
config
sudo make install
cd .. && rm -rf grub-btrfs
Enable services:
sudo systemctl enable --now grub-btrfsd.service
sudo systemctl enable --now snapper-timeline.timer
sudo systemctl enable --now snapper-cleanup.timer
sudo grub2-editenv - unset menu_auto_hide
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Everything’s working snapshots create on schedule, DNF updates trigger pre/post snapshots, can boot from GRUB menu. Any issues with this setup?