Migrate OpenVZ container to another host without node access

Today I received a notice that all Crissic.net OpenVZ VPS customers are cancelled 30 days from now so I needed to figure out fast how to migrate my OpenVZ container to another hosting company. Lucky for me, the process took less than 10 minutes without access to the OpenVZ node. My setup is:

  • OpenVZ container (Ubuntu 14.04.5 LTS)
  • CloudFlare DNS and HTTP proxy
  • SSH access to the OpenVZ container

Prepare new container

  1. I created a new OpenVZ container at RamNode making sure to match the operating system.
  2. Log in through SSH and make sure the system is fully updated
    $ sudo apt-get update && sudo apt-get upgrade -y

Migrate container

  1. Log into the OpenVZ container you want to migrate
  2. Make sure to update the container
    $ sudo apt-get update && sudo apt-get upgrade -y
  3. Using rsync we transfer the content of the container to the destination container. Make sure to replace [email protected] with your own information
    $ sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / [email protected]:/
  4. When the transfer is complete, SSH into the new OpenVZ container. You might get the following warning because of the transfer.
    $ ssh [email protected]
    Someone could be eavesdropping on you right now (man-in-the-middle attack)!
    It is also possible that a host key has just been changed.
    The fingerprint for the ECDSA key sent by the remote host is
    Please contact your system administrator.
    Add correct host key in /Users/newUser/.ssh/known_hosts to get rid of this message.
    Offending ECDSA key in /Users/newUser/.ssh/known_hosts:15
    ECDSA host key for has changed and you have requested strict checking.
    Host key verification failed.

If so, edit the /Users/newUser/.shh/known_hosts file and remove the line containing and try to SSH again.

  1. We reboot the container
    $ sudo reboot
  2. Now we just change the DNS settings and the new container is accessible.
CloudFlare DNS settings


It really only took 10 minutes to migrate the whole setup to RamNode. It took me another 30 minutes to confirm everything was working because I really did not believe it was that easy.

Related Posts