Linux - Migration from a server to another

Solution 1:

In terms of hardware compatibility, if your server does not require proprietary drivers you should be fine. New CPU cores will be detected. One way to find out is to run Debian LiveCD on your server and see what is detected and what is not. With regards to migration you have few options :

- Set up your new server from scratch.

This would probably be most time consuming but a good way to revise your setup for a new environment e.g remove unnecessary packages ( GUI or other desktop packages etc.. ), harden security.

- RSYNC / Copy

Cumbersome but will require least downtime if you need to have you existing server up and running and don't want to set up from scratch.

  • Mount your new server hard drive on your existing system
  • replicate partition layout to mirror your existing system

    sfdisk -d /dev/sda | sfdisk /dev/sdb

    sda is your exisitng server sdb is your new server

  • create filesystem / swap on your new drive partitions and mount root, boot and any other partitions from your new drive on your existing system.

  • copy contents of your existing system to the new drive

    rsync -azv --progress --exclude=proc --exclude=sys --exclude=dev --exclude=/mnt/NEW / /mnt/NEW/
    
    mkdir /mnt/NEW/{proc,sys,dev}
    

    /mnt/NEW is the mountpoint of root (/) from the new drive.

  • repeat for /boot and other partitions if there are any

  • Setup grub on your new drive.

    Run 'grub' and :

    grub> root (hd0,0) 
    grub> setup (hd1)
    

    You might have to modify grub menu.cfg file to update root partition if LABEL is used.
    Commands will vary depending on your partitions layout or if you have raid/LVM etc.. This should leave you with a ready to boot system. If there were changes on your current system while you were doing rsync and you want them to appear on your new system, shut down your system with both drives (current and new ) plugged in and boot into Live CD (SystemRescueCD is great), mount root partitions from both and re-run rsync commands. This should only copy the difference and take little time. Make sure you are copying in the right direction old->new drive.

- DD / Clone

Best option in terms of perfect and easiest migration. This will leave you with an identical copy of you existing system but will require downtime.

Boot your PC with both drives plugged into Live CD (SystemRescueCD is great) and run DD

 dd if=/dev/sda of=/dev/sdb

NOTE : Make sure /dev/sdb is your NEW EMPTY drive. This will take time depending on the size of your disk but when complete your new drive will be ready to boot and will be an identical copy of you current system. Ofcourse your new drive needs to be of the same / larger size.

Your NIC naming will change on the new system, just modify /etc/udev/rules.d/70-persistent-net.rules file and rename as required.

Good luck.

Solution 2:

I think that the better way to migrate is install Debian on the new server and configure it properly , then copy only what you need, for example website root folder, configuration file and so on ...

Do not copy everything but just what you really need is my suggestion.