Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* cloning a btrfs drive with send and receive: clone is bigger than the original?
@ 2021-01-09 16:01  
  2021-01-09 19:45 ` Andrei Borzenkov
  0 siblings, 1 reply; 8+ messages in thread
From:   @ 2021-01-09 16:01 UTC (permalink / raw)
  To: linux-btrfs

­I've got a drive with data, and 3 snapshots of that data. I've transferred all the snapshots to another drive using btrfs send and receive. The send drive has 3.62 GB of data, the receive drive has 4.99 GB of data. It seems like the snapshots don't share data between them that was unchanged.

How can I transfer the snapshots in such a way that the snapshots only occupy the difference between the snapshots?

The data on the original drive is organized like this:
/mnt/send/storage/ <= here's all the data
/mnt/send/storage_snapshots/ <= here are the 3 snapshots

The data on the receiving drive is organized like this:
/mnt/rec/storage/ <= this folder is empty
/mnt/rec/storage_snapshots/ <= here are the 3 snapshots
/mnt/rec/btrfs_receive/ <= here are the 3 files generated by btrfs send 

How can I transfer the snapshots in such a way that /mnt/rec/storage/ holds the latest version of the data, just like on the original drive?

In detail:
# mkfs.btrfs -L SEND /dev/sda3
# mount /dev/sda3 /mnt/send/ -o,compress,noatime
# mkfs.btrfs /dev/sdd2 -L DATA
# mount /dev/sdd2 ./mnt/rec/ -o,compress,noatime
# btrfs subvolume create /mnt/rec/btrfs_receive/
Create subvolume '/mnt/rec/btrfs_receive'
# btrfs subvolume create /mnt/rec/storage_snapshots

# btrfs subvolume create /mnt/send/storage
# btrfs subvolume create /mnt/send/storage_snapshots
# cd /mnt/send/storage
# /home/cedric/mkfiles_and_md5.sh <<generates/ change data on the send drive >>
# btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/storage_snapshots/storage-$(date +%Y_%m_%d-%H%m)
Create a readonly snapshot of '/mnt/send/storage' in '/mnt/send/storage_snapshots/storage-2021_01_09-1301'
# /home/cedric/mkfiles_and_md5.sh <<generates/ change data on the send drive >>
btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/storage_snapshots/storage-$(date +%Y_%m_%d-%H%m%S)
Create a readonly snapshot of '/mnt/send/storage' in '/mnt/send/storage_snapshots/storage-2021_01_09-130120'
# /home/cedric/mkfiles_and_md5.sh <<generates/ change data on the send drive >>
# btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/storage_snapshots/storage-$(date +%Y_%m_%d-%H%m%S)
Create a readonly snapshot of '/mnt/send/storage' in '/mnt/send/storage_snapshots/storage-2021_01_09-130146'

# btrfs send /mnt/send/storage_snapshots/storage-2021_01_09-1301 -f /mnt/rec/btrfs_receive/storage-2021_01_09-1301.btrfssend
At subvol /mnt/send/storage_snapshots/storage-2021_01_09-1301
[root@bcache-test rec]# btrfs send -p /mnt/send/storage_snapshots/storage-2021_01_09-1301 /mnt/send/storage_snapshots/storage-2021_01_09-130120 -f /mnt/rec/btrfs_receive/storage-2021_01_09-130120.btrfssend
At subvol /mnt/send/storage_snapshots/storage-2021_01_09-130120
[root@bcache-test rec]# btrfs send -p /mnt/send/storage_snapshots/storage-2021_01_09-130120 /mnt/send/storage_snapshots/storage-2021_01_09-130146 -f /mnt/rec/btrfs_receive/storage-2021_01_09-130146.btrfssend
At subvol /mnt/send/storage_snapshots/storage-2021_01_09-130146

# btrfs receive -f /mnt/rec/btrfs_receive/storage-2021_01_09-1301.btrfssend  /mnt/rec/storage_snapshots
At subvol storage-2021_01_09-1301
# btrfs receive -f /mnt/rec/btrfs_receive/storage-2021_01_09-130120.btrfssend  /mnt/rec/storage_snapshots
At snapshot storage-2021_01_09-130120
# btrfs receive -f /mnt/rec/btrfs_receive/storage-2021_01_09-130146.btrfssend /mnt/rec/storage_snapshots
At snapshot storage-2021_01_09-130146

# rm /mnt/rec/btrfs_receive/storage-2021_01_09-1301*
# btrfs filesystem show
Label: 'SEND'  uuid: 61b7e45f-62a7-4b04-bc0c-ba1304548b02
	Total devices 1 FS bytes used 3.62GiB
	devid    1 size 5.00GiB used 4.52GiB path /dev/sda3

Label: 'DATA'  uuid: 95e85fa4-217c-429a-be55-833bb63e2c71
	Total devices 1 FS bytes used 4.99GiB
	devid    1 size 931.01GiB used 10.02GiB path /dev/sdd2


---

Take your mailboxes with you. Free, fast and secure Mail &amp; Cloud: https://www.eclipso.eu - Time to change!



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-10 15:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-09 16:01 cloning a btrfs drive with send and receive: clone is bigger than the original?  
2021-01-09 19:45 ` Andrei Borzenkov
2021-01-09 21:08   `  
2021-01-10  7:41     `  
2021-01-10  7:54       ` Andrei Borzenkov
2021-01-10 13:06       ` Re: " Graham Cobb
2021-01-10 13:21         ` Hugo Mills
2021-01-10 15:38           ` Andrei Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox