How to clone a server using just rsync
In the past I needed more space in the server and so i had to upgraded it to a more expensive option, without option of going back
Now the basic server option is cheaper and is enough for me. Plus there were some black friday discounts :)
So I decided to move the server with all my services to a cheaper option and save 75% of what i was spending with more or less the same features
Unfortunately, this is not supported by default and theres no one button way to do it. Fortunately, this is very easy to do using linux!
This is how i did it in 6 easy steps:
- Reboot booh machines using a live image and have a working ssh server on the target server
- Mount the server disk on both servers on /mnt
rsync -AHXavP --numeric-ids --exclude='/mnt/dev' --exclude='/mnt/proc' --exclude='/mnt/sys' /mnt/ email@example.com:/mnt/
- ssh on the target server. Bind /proc /dev /sys to /mnt/ and chroot it
grub-install /dev/sdb && update-grub
ack ip.orig.server /etc/and change it where appropiate
- Change DNS
A couple of hours to do the whole thing including buying the new server and everything seems to be working as if nothing happened. Copying directly from server to server helped with the downtime too. Aint linux wonderful?