Cloning an LVM2 thin pool with all the snapshots

1

Need to clone a 400gb pool onto another machine. Will this work? First I collect the data about the existing pool:

[root@oktest-prod-db-2 ~]# lvdisplay --units B vg_oktestdb2/pool
  --- Logical volume ---
  LV Name                pool
  VG Name                vg_oktestdb2
  LV UUID                tPfUzG-bHW2-jepz-1Sf6-BSmw-jKz4-Tf6djR
  LV Write Access        read/write
  LV Creation host, time oktest-db-2, 2015-03-31 18:55:17 +0300
  LV Pool transaction ID 134
  LV Pool metadata       pool_tmeta
  LV Pool data           pool_tdata
  LV Pool chunk size     262144 B
  LV Zero new blocks     yes
  LV Status              available
  # open                 0
  LV Size                474031849472 B
  Allocated pool data    10.16%
  Allocated metadata     7.66%
  Current LE             113018
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:5

Then create a new pool with the same size:

[root@oktest-prod-db-1-new ~]# lvcreate -L 474031849472b -T vg_oktestdb1/pool --chunksize 256k
  Logical volume "lvol0" created
  Logical volume "pool" created

And lastly copy it over ssh:

[root@oktest-prod-db-2 ~]# dd bs=128k if=/dev/mapper/vg_oktestdb2-pool | ssh root@oktest-prod-db-1-new 'dd bs=128k of=/dev/mapper/vg_oktestdb1-pool'

Now I just sit and wait for several hours

Upd: it did work back then.

basin

Posted 2015-08-27T15:16:04.180

Reputation: 394

Answers

0

Not sure how it goes trough a pipe to a SSH session, but I'm used to do this with netcat

first launch a listening netcat on the destination server :

netcat -p 1237 -l | dd of=<destination lv path/name> obs=$((1024*1024)) ibs=8192

Then on the source server

dd ibs=$((1024*1024)) obs=8192 <source lv path/name>  | pv | netcat <ip of destination server> 1237

you can skip the "pv" part of course and change the port "1237" to whatever will pass trough your firewalls.

Also you can pipe it into gzip but from my experience this is not a big gain.

JFL

Posted 2015-08-27T15:16:04.180

Reputation: 272

Was it a thin pool? – basin – 2015-08-27T17:05:55.067