Cloning a remote Linux server

I recently had a client require us to clone their existing hosted virtual linux server to a new datacentre.

It was too difficult for them to p2v or anything like because they didn’t have the necessary access to virtual environment it all sat on.

So a solution I put together through reading various comments on various forums was as follows to resolve this problem.

I setup an SSH server that I could remote into from the server I was to clone.

  • I then SSH’d into the Remote Computer
  • Ran the following command
  • dd if=/dev/sda | gzip -1 – | ssh user@local dd of=backup.img.gz
  • NB: sda is the disk on the originating server I was copying and the user@local was the username @ the host that I setup with SSH for the image to be delivered to.
  • Once that was finished, I moved onto the destination server
  • I created a virtual host template with the same spec’s as the original server I was cloning
  • I booted that image with a rescue os like System Rescue CD
  • I pulled the file down from my SSH receiving server from earlier
  • I then ran the reverse of the previous command to clone the image back to the new disk
  • gunzip -c /path/to/backup.img.gz | dd of=/dev/sdX
    • X being the disk on the destination which will have all of its contents replaced by the image. including boot flags etc
  • You will most likely need to fix up the networking and install vmware tools or similar on the destination but that should be it. After a reboot it should be good to go!

You can actually do it directly via SSH if you really want to live crazy and skip a few steps.

If you really want to know how, leave me a comment and i’ll tell you how

Posted in Notes and tagged , .