I maintain a series of hourly snapshots on my btrfs filesystem using btrbk. The subvolume and snapshots are stored like this (names shortened to make it easier to follow):
/@vol (subvolume) /email@example.com (snapshots of /@vol, one per hour) /firstname.lastname@example.org ... /home/user/vol (mountpoint for /@vol)
Now I deleted a single file in
/home/user/vol which I should not have deleted. No problem, I can easily restore from the latest snapshot:
# cd /home/user/vol # cp -a --reflink=always /email@example.com/all_ipv4_numbers.txt ./ cp: failed to clone './all_ipv4_numbers.txt' from '/firstname.lastname@example.org/all_ipv4_numbers.txt': Invalid cross-device link
Seems I can't "reflink" the file. But I don't want to end up with two copies of the file. Ideally I want it to look like nothing happened between the most recent snapshot and the next snapshot that will be taken in the future.
(Yes, I also have actual backups, but restoring from snapshots are more convenient whenever available!)
How do I restore a single file from a btrfs snapshot while keeping all the nice references and magic that makes btrfs know that it is the same data in all the snapshots?