thomjiji

btrfs and btrbk

2023-12-01 · btrfs btrbk snapshot Linux

/etc/btrbk/btrbk.conf config file:

volume /
  snapshot_dir btrbk_snapshots
  subvolume home
  incremental strict

Key points:


What is snapshot?

Every Btrfs snapshot is a subvolume. However, not every subvolume is a snapshot. The difference is in what the subvolume contains. A snapshot is a subvolume with added content: it holds references to current and/or past versions of files (inodes). — Working with Btrfs – Snapshots | Snapshots in Btrfs


似乎,btrbk 说的 snapshot 指的是与原系统 filesystem 存储在一起的 snapshot,而 backup 指的是在另一个独立的 filesystem 下的 snapshot。与原 filesystem 存在一起的 snapshot 不能称作是一个 backup,因为如果原 filesystem 炸了,那么 snapshot 一起完蛋。而 backup 这时候可以发挥作用了,因为它是存在另一个 filesystem 下的,一般来说是存在另一个盘上,这样才是 backup。以下是 btrbk man page 对 btrfs snapshot 和 btrbk snapshot 区别的简短说明:

Note that in btrfs terminology, a snapshot is a “subvolume with a given initial content of the original subvolume” (showing a parent-uuid, see btrfs-subvolume(8)), and they can be read-write (default) or read-only. In btrbk terminology, snapshot means “read-only btrfs snapshot”, and backup means “read-only subvolume created with send/receive” (showing a received-uuid). — man btrbk

可以得知,btrbk 创建的 snapshot 默认是 readonly 的,btrfs 默认是 read 和 write。而 btrbk 的 backup 的概念为:使用 btrfs send 和 btrfs receive 命令创建的 readonly 的 snapshot (sumvolume),而 send/receive 命令一般来说用于在不同 btrfs 文件系统之间移动 snapshots,可以说就是在不同盘之间移动数据。因此,我们上面的理解与 btrbk 的说明相符。

btrbk.conf 的 target 就是 backup 存放的地方,而 snapshot_dir 顾名思义是 snapshot 存放的地方。


References: