Recently i had to migrate my servers from a Virtualbox instances to KVM and LXC containers. ( this guide is also valid for Desktop PC)
Before that i simply move the .vdi file from a machine to another, but .vdi are not compatible with KVM/LXC formats. Moreover converting .vdi to .raw (compatible format for kvm/lxc) is not a good practice since your system will be probably broken.
But, i'm an extremely lazy person...so how can i migrate a server without a long manual process of reinstalling , reconfiguring and moving file?
After some researches i've found this wonderful guide: https://lowendbox.com/blog/how-to-migrate-a-hosted-server-in-5-easy-steps-with-rsync/
I want to summarize and improve it for you (the process will take 5-10 human minutes + the variable upload time):
NOTE: you must be logged as root user before execute following commands.
Step1:
First of all, you need to have both machines powered up.
Assure that you have same linux os version on both machines, if not do the upgrade.
Step2:
Run:
Step 3:
Rsync is able to syncronize the entire system even if it's in running. You just have to exclude some folder that are machine related.
Run
Step 4:
This step is needed since rsync is not able to overwrite following files.
Run
mv /tmp/passwd /etc/
mv /tmp/shadow /etc/
mv /tmp/gshadow /etc/
mv /tmp/group /etc/
Before that i simply move the .vdi file from a machine to another, but .vdi are not compatible with KVM/LXC formats. Moreover converting .vdi to .raw (compatible format for kvm/lxc) is not a good practice since your system will be probably broken.
But, i'm an extremely lazy person...so how can i migrate a server without a long manual process of reinstalling , reconfiguring and moving file?
After some researches i've found this wonderful guide: https://lowendbox.com/blog/how-to-migrate-a-hosted-server-in-5-easy-steps-with-rsync/
I want to summarize and improve it for you (the process will take 5-10 human minutes + the variable upload time):
NOTE: you must be logged as root user before execute following commands.
Step1:
First of all, you need to have both machines powered up.
Assure that you have same linux os version on both machines, if not do the upgrade.
Step2:
Run:
apt-get update; apt-get upgrade; apt-get dist-upgradeon both machines
Step 3:
Rsync is able to syncronize the entire system even if it's in running. You just have to exclude some folder that are machine related.
Run
rsync -auHxv --numeric-ids --exclude=/etc/fstab --exclude=/etc/network/* --exclude=/proc/* --exclude=/tmp/* --exclude=/sys/* --exclude=/dev/* --exclude=/mnt/* --exclude=/boot/* --exclude=/root/* root@SRC-IP:/* /on destination machine (replace SRC-IP with the ip of the source machine)
Step 4:
This step is needed since rsync is not able to overwrite following files.
Run
rsync -auHxv --numeric-ids root@SRC-IP:/etc/passwd /tmp/
rsync -auHxv --numeric-ids root@SRC-IP:/etc/shadow /tmp/
rsync -auHxv --numeric-ids root@SRC-IP:/etc/gshadow /tmp/rsync -auHxv --numeric-ids root@SRC-IP:/etc/group /tmp/
mv /tmp/passwd /etc/
mv /tmp/shadow /etc/
mv /tmp/gshadow /etc/
mv /tmp/group /etc/
After that, reboot your destination machine and change your IP/Domain destination.
Reconfigure the /etc/network/interface if you are moving a failover IP.
I hope it can help someone!
At least for me, it has been as faster as move a .vdi and reconfiguring the virtualbox instance!
At least for me, it has been as faster as move a .vdi and reconfiguring the virtualbox instance!
Please leave a comment about your experience
Commenti
Posta un commento