Difficulty: ★★★☆☆
This is a wiki post, so feel free to contribute (but please stay on topic)
Btrfs is a very different file system (compared to others). Some parts even look weird. send/receive btrfs is weird !
Btrfs send
Takes an existing snapshot (read-only) and converts it to a data stream.
Btrfs receive
Takes a data stream and creates a snapshot (and makes it read-only)
Every command on this wiki must be run as root
, or with sudo
Copy
If you pipe
send
to receive
, a copy of the snapshot will be made.
This is the easiest way to copy an snapshot from one btrfs-volume to another
Provided
- You have snapshots of /home at /home/.snapshots/ like
snapper
does - There is a snapshot named /home/.snapshots/23/snapshot
- You mounted a Btrfs subvolume in /mnt/BACKUP
- There is a directory /mnt/BACKUP/23/
btrfs send /home/.snapshots/23/snapshot | btrfs receive /mnt/BACKUP/23
The snapshot present in /home/.snapshots/23/ is copied to /mnt/BACKUP/23 .
Copy with progress
Since btrfs send / receive does not show any progress, and this can take some time (!), I suggest to use pv
to show the progress. ( pv
must be installed beforehand)
btrfs send /home/.snapshots/24/snapshot | pv | btrfs receive /mnt/BACKUP/24
Use the parent snapshot
- to speed things up
- to save space
You now have two snapshots on your backup that contain mostly the same files. But they don’t share a single byte of storage! The second one is nearly the same size as the first. This is not space saving. And the copy of the second snapshot took almost as long to copy as the first. That’s is not efficient!
When sending a snapshot, btrfs send
can send differences between snapshots if you specify which snapshot was the “parent”.
Assumed:
- You have an snapshot of /home at /home/.snapshots/24/snapshot
- You have a copy(backup) of this snapshot at /mnt/BACKUP/24/snapshot
- You have a snapshot of /home at /home/.snapshots/25/snapshot
btrfs send -p /home/.snapshots/24/snapshot /home/.snapshots/25/snapshot | pv | btrfs receive /mnt/BACKUP/25
Btrfs send
searches for the parent and only transmits the parent UUID and the stream of changed files.
Btrfs receive
looks for the existing copy of the parent using the UUID. Then it creates a new snapshot depending on the copy of the parent snapshot.
This is work in progress as of 8.3.23