the f*ck rants about stuff

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!

People fighting over products in black friday fashion

This is how i did it in 6 easy steps:

Step 1

  • 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

Step 2

  • rsync -AHXavP --numeric-ids --exclude='/mnt/dev' --exclude='/mnt/proc' --exclude='/mnt/sys' /mnt/ root@ip.dest.server:/mnt/

Step 3

  • 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
  • reboot

Step 4

  • Change DNS

Step 5

  • ????

Step 6

  • Profit!
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?

If you liked this, I think you might be interested in some of these related articles:

¡ En Español !