transfer_disk_with_netcat
Recently I had to move some VPSes from one server to another, as the old server was being shut down (new cheaper and faster host). To minimize the downtime, I took data from one LVM volume and put it directly in the LVM of the new server.
Receiving side:
time nc -l 19000 | pigz -d -k -c - | dd of=/dev/vps-vg/vps04
Explanation:
- I use “time” just for stats (so it's not required)
- I set up a listening netcat socket on port 19000, awaiting data from the “sending side”
- I decompress incoming data from netcat with pigz (“-” is for data coming from “stdin”)
- Finally I put the decompressed data into the new LVM volume with “dd” (dd grabs its data from stdin if no “if” parameter is set)
Sending side:
dd if=/dev/vg0/vps04 bs=4096k | pigz -9 -b 4096 -c | nc RECEIVING.SERVER.TLD 19000
Explanation:
- I read the data with dd
- I compress it with pigz
- I then use netcat to send the data.
NOTE: You need to start the “receiving side” first, otherwise the “sending side” will fail due to netcat being unable to establish a connection.
transfer_disk_with_netcat.txt · Last modified: 2015/08/15 22:56 by 127.0.0.1