How do I transfer /home and /home/.snapshots to a new machine?

I have a laptop running F39 and I’m using snapper for snapshots of my home directory, and it has worked great. I have a new laptop that I’ve installed F39 on, and what I’d like to do is clone my home directory and all the snapshots to the new machine. Here’s the layout (there are more snapshots, I truncated the list):

# btrfs subvolume list /
ID 256 gen 595680 top level 5 path home
ID 259 gen 595680 top level 5 path root
ID 260 gen 591394 top level 259 path var/lib/machines
ID 261 gen 595478 top level 256 path home/.snapshots
ID 262 gen 544947 top level 261 path home/.snapshots/1/snapshot
ID 339 gen 551938 top level 261 path home/.snapshots/78/snapshot
ID 465 gen 564136 top level 261 path home/.snapshots/204/snapshot
ID 539 gen 571348 top level 261 path home/.snapshots/278/snapshot
ID 617 gen 579073 top level 261 path home/.snapshots/356/snapshot

# snapper list -a
   # | Type   | Pre # | Date                        | User | Cleanup  | Description | Userdata
-----+--------+-------+-----------------------------+------+----------+-------------+---------
  0  | single |       |                             | root |          | current     |         
  1  | single |       | Mon 18 Dec 2023 12:00:09 PM | root | timeline | timeline    |         
 78  | single |       | Mon 01 Jan 2024 03:42:11 PM | root | timeline | timeline    |         
204  | single |       | Mon 15 Jan 2024 01:57:37 PM | root | timeline | timeline    |         
278  | single |       | Mon 22 Jan 2024 08:47:39 AM | root | timeline | timeline    |         
356  | single |       | Mon 29 Jan 2024 08:40:30 AM | root | timeline | timeline    |         

# btrfs subvolume list -qu --sort ogen /home/
ID 256 gen 595679 top level 5 parent_uuid -                                    uuid e16ed711-4ca2-a742-a027-e43e9f8a71f3 path home
ID 259 gen 595679 top level 5 parent_uuid -                                    uuid 66fd73cf-4042-e848-a3eb-e3447b23f172 path root
ID 260 gen 591394 top level 259 parent_uuid -                                    uuid 88694a80-93d6-7d4d-9338-09e0d09ad73e path root/var/lib/machines
ID 261 gen 595478 top level 256 parent_uuid -                                    uuid 155ede29-8434-5a47-9f21-54b68d07c697 path .snapshots
ID 262 gen 544947 top level 261 parent_uuid e16ed711-4ca2-a742-a027-e43e9f8a71f3 uuid 6bbe9145-c44a-c245-8958-8e794e25313c path .snapshots/1/snapshot
ID 339 gen 551938 top level 261 parent_uuid e16ed711-4ca2-a742-a027-e43e9f8a71f3 uuid a5dc1538-099a-5c45-8008-60fc01cdbd99 path .snapshots/78/snapshot
ID 465 gen 564136 top level 261 parent_uuid e16ed711-4ca2-a742-a027-e43e9f8a71f3 uuid e7c580f0-ba01-7b46-a532-98b4a4adf34d path .snapshots/204/snapshot
ID 539 gen 571348 top level 261 parent_uuid e16ed711-4ca2-a742-a027-e43e9f8a71f3 uuid 93a527cc-7a87-f442-8a15-b9044f7a7b15 path .snapshots/278/snapshot
ID 617 gen 579073 top level 261 parent_uuid e16ed711-4ca2-a742-a027-e43e9f8a71f3 uuid 117c1f44-af27-684e-bdfc-ef4952bef7e7 path .snapshots/356/snapshot

To transfer the home volume, I first created a file and then transferred to the new machine with rsync (as my network is not great). At the other end I can use btrfs receive.

# btrfs property set -ts /home ro true
# btrfs send /home -f /home.sub
# rsync -avz --append /home.sub newmachine:/

Now I want to transfer the snapshots, so my understanding is I need to create them with the parent matching the parent UUID given above, so I tried this, but it fails:

# btrfs send -f /1.sub -p /home /home/.snapshots/1
ERROR: not on mount point: /home

I tried a bunch of other things, but I’m just confusing myself now. Is what I want to do possible? How do I transfer the snapshots with setting the parent in this setup?

Hello @switchyrascal ,
To transfer using btrfs send/receive you would pipe the output of send to the input of receive sort of like … btrfs send /home_backup | btrfs receive /backup
[Edit] The /home_backup is a ro subvolume to be clear, and the /backup is the volume location you wan to create the (new) subvolume in.

Piping is fine to a local machine, but to do the transfer to another machine you can use ssh or rsync for example. Piping through ssh has the downside that if the btrfs-send/btrfs-receive fails, you have to start all over again, but with rsync you can resume transferring the file and deal with it at the other end. However, what I’m really trying to figure out is whether the home and snapshots can be transferred to a new F39 install, and I’m not sure they can be. Parts I’m not sure about: how to get /home on the new machine to use a new volume from the btrfs-receive since /home is at the root volume level, and how to get the parent of the snapshots that are sent to be set correctly?

I have done a new install with my old home in place, and also as a snapshot of my original subvolume. In that case (snapshot) I used my backup USB connected drive and used send/receive, so yes local. I had to copy my user setup from the original installation (in /etc I think) and relabel my home for selinux, and change the firstboot file to yes for the question it poses. I did this because of replacing my spinning disk that held / and /var with an ssd of larger space. This was a number of releases ago, shortly after converting to btrfs in my case. The ‘steps’ I mention are just from memory, so please take that into account.

I’ll try to explain a bit better, since I’m trying to do something different to the case you solved. Here’s an example output from btrfs-subvol-list where I’ve mimicked the btrfs setup used by F39, in /root/old. I took a btrfs-send of all the /root/old subvolume structure (including snapshots) , then tried to rebuild the structure using those files in /root/new. See how the parent UUIDs of the snapshots still point to the old home? That’s the issue. Because on the new machine, the parent UUID of the snapshots won’t exist (in this case it should be cfcfb23f not 74e679e3). Is it possible to change it? Does it matter? In the end I would like to have the entire old home+snapshots mirrored correctly to a new machine with the correct incremental snapshots. I think I must be missing something on how to do this.

ID 1134 gen 597339 top level 259 parent_uuid -                                    uuid 74e679e3-1a42-734d-95d8-1ed35c1edf1b path root/old/home
ID 1135 gen 597325 top level 1134 parent_uuid -                                    uuid 6ca63822-d179-174f-99b8-d5ebdbd4e73a path root/old/home/.snapshots
ID 1136 gen 597324 top level 1135 parent_uuid 74e679e3-1a42-734d-95d8-1ed35c1edf1b uuid e4d1ee40-8b2f-1d45-ad00-7e378f213671 path root/old/home/.snapshots/1/snapshot
ID 1137 gen 597325 top level 1135 parent_uuid 74e679e3-1a42-734d-95d8-1ed35c1edf1b uuid ebb21848-35b5-5f40-b629-7122c25e2c2a path root/old/home/.snapshots/2/snapshot
ID 1138 gen 597332 top level 259 parent_uuid -                                    uuid cfcfb23f-3203-cc42-b89f-9a076d821667 path root/new/home
ID 1139 gen 597339 top level 1138 parent_uuid -                                    uuid a8541977-4de0-a44a-96da-a22030fbe483 path root/new/home/.snapshots
ID 1140 gen 597337 top level 1139 parent_uuid 74e679e3-1a42-734d-95d8-1ed35c1edf1b uuid cee0045c-aaaf-9140-abf4-be6c4e2c0495 path root/new/home/.snapshots/1/snapshot
ID 1141 gen 597339 top level 1139 parent_uuid 74e679e3-1a42-734d-95d8-1ed35c1edf1b uuid d25cbc25-5fec-814e-a81c-ea307d6328eb path root/new/home/.snapshots/2/snapshot

Hello @switchyrascal
Maybe you should be looking into how to setup systemd-homed for this use case. It is sounding sort of relevant.