How to migrate server data?

  • One option can be:

    i didn't have test it, but

    i think, make snapshot, export on old, and import/move on new

    update IP setting's and fine...

    the only what u have to check, is the free SPACE to create and rebuild.

    jeder der einen Schreibfehler in meinem Post findet, darf ihn Kommentarlos behalten

    P.S. gilt auch für Schignaturen ;)

  • If the question is still acute, resp. interesting for other people may still need that...

    1. Backup/make Snapshot/whatever is needed (in order to restore if something below were going wrong).
    2. Be sure you've same system (distribution/revision) installed on both hosts, so do update/upgrade on both sides.
      Also check rsync is installed.
    3. Reboot both and login as root (or sudo -s) on source and target systems
    4. If you want migrate some kernel-less system (container virtual guest) like OpenVZ, LXC, etc to host with a kernel (KVM, etc) you have to install getty or mingetty and enable tty's, otherwise simply bypass this step.
      You can also do that later if you've (chroot capable) live CD, but better at least install mingetty before you start migration.
      On the source VM:
      apt install mingetty
      then edit inittab
      nano /etc/inittab
      and add this lines or check they are already there:
      Code
      1. # Run gettys in standard run levels
      2. 1:2345:respawn:/sbin/mingetty tty1
      3. 2:2345:respawn:/sbin/mingetty tty2
      4. 3:2345:respawn:/sbin/mingetty tty3
      5. 4:2345:respawn:/sbin/mingetty tty4
      6. 5:2345:respawn:/sbin/mingetty tty5
      7. 6:2345:respawn:/sbin/mingetty tty6
    5. Now on the source host create an exclude list /tmp/rsexcl.txt for rsync (directory names which should be ignored by migration):
      { for i in /boot /proc /sys /tmp /dev /run /var/run /var/lock /etc/fstab /etc/mtab /etc/resolv.conf /etc/conf.d/net /etc/network/interfaces /etc/networks '/etc/sysconfig/network*' /etc/sysconfig/hwconf /etc/sysconfig/ip6tables-config /etc/sysconfig/kernel /etc/hostname /etc/HOSTNAME /etc/hosts '/etc/modprobe*' /etc/modules /net /lib/modules /etc/rc.conf '/usr/share/nova-agent*' '/usr/sbin/nova-agent*' '/etc/init.d/nova-agent*' /etc/ips /etc/ipaddrpool /etc/ips.dnsmaster /etc/resolv.conf /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/udev /lib/udev; do echo "$i"; done; } > /tmp/rsexcl.txt
      You can also add your own large directories (e. g. /var/mail, /home/user/data) to this file in order to speedup initial step of migration (they will be copied at end, see step 9).
    6. And start the initial migration (replace TARGET-SERVER with IP or name of your target host):
      rsync --exclude-from="/tmp/rsexcl.txt" --delete --numeric-ids -avpogtStlHz -e "ssh -o Compression=no" / root@TARGET-SERVER:/
      Now wait until it gets ready.
    7. Then switch to target host and reboot it.
      If it does not boot successfully, boot from LiveCD in rescue mode, select your root and start shell.
      Then try to reinstall and update grub:
      Code
      1. apt-get install --reinstall grub
      2. update-grub
      It should be bootable now.
    8. Check and change in case of need the remaining configuration like network interfaces, IPs, etc.
      Sometimes tty1 is disabled (you've terminal on tty2..tty6 only), if you need it, just enable `getty@tty1` service (here for systemd):
      systemctl enable getty@tty1
    9. Now you can copy the rest of your data (here the 2 remaining directories that have been added in exclude-list in step 5):
      rsync --numeric-ids -avpogtStlHz --relative -e "ssh -o Compression=no" /var/mail /home/user/data root@TARGET-SERVER:/
      You can repeat this several times in order to do an incremental update, if your domains are not yet actualized and some mails still delivered to the old (source) host. Don't use --delete option here (so only new mails or data).

    That's it.