Linux – What’s the difference between “parent” and “clone source” with “btrfs send”

backupbtrfslinuxsynchronization

I regularly use btrfs send and btrfs receive to copy read-only snapshots from my live system to a backup drive. On the backup drive there are already multiple snapshots. Today I wondered: Can I copy multiple of today's snapshots as incremental update from multiple older snapshots at once?

Recently I did

btrfs send -p  home_old  home_today | btrfs receive /mnt/backup/
btrfs send -p share_old share_today | btrfs receive /mnt/backup/

Could this be unified to 1 command?

So I looked into man btrfs-send and read:

In the incremental mode (options -p and -c), previously sent snapshots that are available on both the sending and receiving side can be used to reduce the amount of information that has to be sent to reconstruct the sent snapshot on a different filesystem.

That's what I want.

-p <parent>

send an incremental stream from parent to subvol

-c <clone-src>

use this snapshot as a clone source for an incremental send (multiple allowed)

It seems that only one of -p and -c supports multiple existing snapshots but I don't get the difference between them. What's the difference?

Best Answer

Here it says that with -p btrfs-send first creates snapshot of parent subvolume and then modifies that snapshot accordingly to data stream from btrfs-send. With -c option btrfs-receive creates blank subvolume and modifies it, creating reflinks for unchanged files. The difference is the size of metadata btrfs-send needs to transfer. In case of -c option all metadata is transfered, in case of -p option -- some metadata.

I tested this with snapshots of subvolume (250G, 310k files) with these results:

# time btrfs send -p server-20181031-1746 server-20181225-1144 -f /mnt/parent.diff
At subvol server-20181225-1144

real    3m12,618s

Size of parent.diff is 6418364996 bytes

# time btrfs send -c server-20181031-1746 server-20181225-1144 -f /mnt/clone.diff
At subvol server-20181225-1144

real    3m17,435s

Size of parent.diff is 6418364996 bytes

So, in my case there is almost no difference.

I don't think btrfs-send can generate streams for multiple subvolumes in one command.

Related Question