D   A   T   A   W   O   K

Creation: March 29 2021
Modified: March 29 2021

Btrfs Snapshots

Snapshot feature of Btrfs uses the Copy-on-Write (CoW) strategy. So it doesn't take much disk space and snapshots of subvolumes are instantaneous.

Two snapshot types:

Take a read-only snapshot of the root filesystem.

    $ btrfs subvolume snapshot -r / /.snapshots/snap1

Snapshots will not take recursive snapshots of themselves. If you create a snapshot of a subvolume, every subvolume or snapshot that the subvolume contains is mapped to an empty directory of the same name inside the snapshot.

To view snapshot subvolume details:

    $ btrfs subvolume show /.shapshots/snap1

Send and Receive

Is possible to transfer the snapshot to another Btrfs volume (e.g. on an external hard drive). Note that the destination is required to be a Btrfs volume.

The command to send the snapshot to the destination is:

    $ btrfs send /.snapshots/snap1 | sudo btrfs receive /run/media/user/mydisk/bk

This is called initial bootstrapping, and it corresponds to a full backup. This task will take some time, depending on the size of the snapshot directory. Obviously, subsequent incremental sends will take a shorter time.


Take another snapshot.

    $ btrfs subvolume snapshot -r / /.snapshots/snap2

Send only the differences.

    $ btrfs send -p /.snapshots/snap1 /.snapshots/snap2 | sudo btrfs receive /run/media/user/mydisk/bk


To restore a previous snapshot is sufficient to manually restore it.

There are different solutions: we can use mv, rsync or btrfs tool.

Using rysnc:

    $ rsync -arv --progress .snapshots/home_snapshot/* /home/dave

Using btrfs

    $ btrfs subvolume snapshot /.snapshots/home_snapshot /home/dave

proudly self-hosted on a cheap Raspberry Pi 2