If I send a btrfs incremental stream from drive1 (using -p to refer the last snap) and I receive it on drive2, how does btrfs know which snap on drive2 it should link the stream to (since -p is for the source only, not for the destination)? Does btrfs try to find the same path on the destination or does it try to match it with some more sophisticated logic (for example, matching the ID of the snapshot)?
Matching is done via the subvolume UUID assigned and unique to each subvolume. Additionally subvolumes may have a Parent UUID for the subvolume they are a snapshot of and a Received UUID for the source UUID of subvolumes received via
You can see these using
btrfs subvolume show <volume>:
$ btrfs subvolume show /mnt/btrfs/subvolume /mnt/btrfs/subvolume Name: subvolume UUID: 5e076a14-4e42-254d-ac8e-55bebea982d1 Parent UUID: - Received UUID: - Creation time: 2018-01-01 12:34:56 +0000 Subvolume ID: 79 Generation: 2844 Gen at creation: 2844 Parent ID: 5 Top level ID: 5 Flags: - Snapshot(s):