Migrate whole system from one host to another
Written by Simone
I recently moved from OVH to Contabo for my VPS: since setting up everything from scratch looked like a hard challenge, I moved everything using rsync
.
Firstly, some preparations:
- installed the same kernel I had on OVH
- rebooted Contabo
- installed rsync on Contabo
Then I switched to the OVH shell:
- created a
exclude.txt
file with all the directory and file I didn't want to move:
/boot/
/etc/modules
/etc/fstab
/etc/mtab
/etc/netconfig
/etc/networks
/etc/network/
/etc/ssh/
/etc/cloud/
/etc/cloud-release
/etc/grub.d/
/etc/host.conf
/etc/hostname
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/init.d/cloud-config
/etc/init.d/cloud-final
/etc/init.d/cloud-init
/etc/init.d/cloud-init-local
/etc/initramfs-tools/
/etc/default/grub
/etc/default/grub.d/
/etc/kernel/
/etc/kernel-img.conf
/lib/modules/
/lost+found/
/sys/
/proc/
/dev/
/tmp/
/var/cache/
/var/log/journal/
/mnt/
/root/.ssh/
-
moved it to
/root/exclude.txt
-
stopped all the running services
systemctl stop
-
now we can begin rsync-ing: you have to have access to the root user on destination VPS
rsync -avzP --exclude-from=/root/exclude.txt / root@CONTABO_IP:/
-
after that, I edited
/etc/fstab
to add support for quota, like I had on OVH -
then I searched and grepped
/etc
for my OVH IP address, because I knew it was set somewhere on some config filegrep -r “OVH IP” /etc/*
-
and substituted it with the new Contabo IP, where necessary.
Finally, I could reboot Contabo:
reboot
Once up & running again, I changed all DNS entries from OVH to Contabo IP.. And waited 😀
-
Last but not least, I edited
etc/hosts
manually to reflect the new Domain Name address and also set up thehostname
hostnamectl set-hostname
Done!
EDIT! A detail I missed to mention is that your destination host's root password will be changed, after rsync-ing, to the one of the source host!!