Automated snapshots with Btrfs
Sun, Oct 1, 2023 02:00 CEST
Tags: Arch Linux, Btrfs, Backup, Snapshots, snapper, snap-pac, pacman
Install snapper
pacman -S snapper
Make sure to have followed
snapper
’s recommendations regarding Btrfs subvolumes layout.
Note that snapper
creates a subvolume for snapshots at /.snapshots
but with
an unnecessary parent dependency on @
.
To allow snapper
to go through the configuration step, make sure you have
unmounted any subvolume (or other) mounted at /.snaphosts
and deleted any
corresponding directory.
umount /.snapshots
rm -r /.snapshots
Create configuration for the root subvolume
snapper -c root create-config /
Then delete the subvolume automatically created by snapper
btrfs subvolume delete /.snapshots
And replace it with an independent @snapshots
subvolume (if you had already
created it, mkdir /.snapshots && mount -a
should suffice).
Existing configurations can be listed with
snapper list-configs
You can edit configurations under /etc/snapper/configs/
.
To enable automatic timeline snapshots simply install cronie
and enable the corresponding systemd system service:
pacman -S cronie
systemctl enable --now cronie
To enable automatic pacman transactions snapshots, install snap-pac
:
pacman -S snap-pac
You can configure snap-pac
at /etc/snap-pac.ini
.
To enable automatic snapshots on boot, enable snapper-boot.timer
:
systemctl enable --now snapper-boot.timer
Existing snapshots can be listed with
snapper list
See also: