Btrbk setup - nutthawit/alpine-dotfile GitHub Wiki
Btrbk is a backup tool for btrfs subvolumes, taking advantage of btrfs specific capabilities to create atomic snapshots and transfer them incrementally to your backup locations.
Installation
Install btrbk
apk add btrbk btrbk-doc
Configuration
Mount root partition to /mnt/btr_pool and add entry to /etc/fstab
ROOT=/dev/nvme0n1p2
BTR_POOL=/mnt/btr_pool
echo "${ROOT} ${BTR_POOL} btrfs subvolid=5,noatime 0 0" | tee -a /etc/fstab
mkdir ${BTR_POOL}
mount -a
mount
[!CAUTION] Mounting
subvolid=5is mandatory if you want to backup your root filesystem/
[!NOTE] subvolid=5 is known as the fs_tree. The fs_tree is automatically created when you create a Btrfs filesystem using
mkfs.btrfs
As of now, my subvolume scheme is the following:
| Name | Path | Mount |
|---|---|---|
| @ | / | / |
| home | /home | /home |
| var | /var | /var |
All subvolumes are children of the top-level (ID 5). This is the output of my btrfs subvolume list / command.
ID 256 gen 176 top level 5 path @
ID 257 gen 10 top level 5 path home
ID 258 gen 173 top level 5 path var
And this is my /etc/fstab. Focus on the first three lines.
UUID=f6cfb7d1-dbcf-4680-830c-2f6aa89d8c50 / btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@ 0 1
UUID=f6cfb7d1-dbcf-4680-830c-2f6aa89d8c50 /home btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/home 0 2
UUID=f6cfb7d1-dbcf-4680-830c-2f6aa89d8c50 /var btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/var 0 2
UUID=68D7-7AE4 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro 0 2
/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0
/dev/usbdisk /media/usb vfat noauto 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
/dev/nvme0n1p2 /mnt/btr_pool btrfs subvolid=5,noatime 0 0