Copying LVM Containers from One Remote Server to Another
Saturday, April 27th, 2019Transferring LVM Containers
Before you transfer a KVM container to another machine, create a KVM virtual machine on the target server with the same or larger disk size than the container being transferred.
You can see a full list of LVM containers by using the below command:
sudo lvdisplay
Copying an LVM Container from the Local Machine to a Remote Server
sudo -i dd if=/dev/vms/phpdev bs=4096 | pv | ssh root@IPADDRESS_HERE -p SSH_PORT 'dd of=/dev/pool/phpdev bs=4096'
Adjust the above pool paths as necessary since this may vary from server to server.
Copying an LVM Container from a Remote Machine to the Local Machine
sudo -i ssh root@IPADDRESS_HERE -p SSH_PORT "dd if=/dev/vms/phpdev bs=4096" | dd of="/dev/vms/phpdev" bs="4096"
Adjust the above pool paths as necessary since this may vary from server to server.
With SSH Passphrase Key
If you're using an SSH key that is protected with a passphrase, use the below commands to open the key, provide the passphrase for that key, and copy the containers without being prompted for the passphrase when the container transfer begins:
sudo -i eval $(ssh-agent) ssh-add /root/keys/{PATH_TO_KEY} dd if=/dev/pool/test bs=4096 | pv | ssh root@host.com -p {PORT} -i /root/keys/{PATH_TO_KEY} 'dd of=/dev/haha/test bs=4096'