There are two variants:

  • import from a server with VMmanager OVZ;
  • import from a server with a third-party control panel. 

Importing virtual machines from a server with VMmanager OVZ


  1. To import a container you need to have two servers with VMmanager OVZ. Put the public key of the source server on the target server. Execute the following command on the source server:

    ssh-keygen -t rsa
    ssh-copy-id -i /root/.ssh/id_rsa.pub root@<server IP address>
    BASH
    <Server IP address> — IP address of the target server
  2. In VMmanager database create a record about the container. Access the target server with root-permissions and execute the API-request: 

    https:/ip:1500/vemgr?admdown=off&chratein=1000&chrateout=1000&comments=&cpu=1&cpufreq=1000&domain=domain.com&func=vm.create&hdd=4000&hostnode=1&ip=xxx.xx.xx.x&layout=ploop&mem=512&name=example&numfile=16536&numproc=5000&ostemplate=template&password=*&swapratio=0&user_id=yy&vmnote
    BASH

    Enter the value of the imported container as the request parameters:

    chratein and chrateout — incoming and outgoing traffic limits.

    cpu — number of CPU.

    cpufreq — CPU frequency.

    domain — container domain name.

    hdd — HDD size.

    hostnode — id of the cluster node where the container will be located.

    ip — container IP-address.

    layout — container file system.

    mem — RAM.

    numfile — file descriptor limit.

    numproc — CPU limit.

    ostemplate — OS template.

    password — password.

    swapratio — Swap/Ram ratio.

    user_id — id of the container owner.

  3. After you have started the request, you will see the confirmation window in the browser. Add &out=xml at the end of the request and click OK. Thus, you will create a "false" container that in fact does not exist on the hard drive. 
  4. Suspend the container on the source server.
  5. Import the configuration file of the container. By default, the configuration files are located in /etc/vz/conf. On the source server execute the command: 

    rsync -avz /etc/vz/conf/<id.conf> root@<IP-address of the cluster node>:/etc/vz/conf/<id.conf>
    BASH

    <IP-address of the cluster node> — IP-address of the cluster node the container will be imported to.
    <id.conf> — id of the false container of the control panel (you can see it in the interface).

  6. To import the container, execute the command on the source server: 

    rsync -avz /var/lib/vz/private/<id-old>/ root@<IP-address of the cluster node>:/var/lib/vz/private/<id>
    BASH

    <IP-address of the cluster node> — IP-address of the cluster node the container will be imported to.

    <id-old> — container id on the source server.
    <id> — id of the false container.
  7. Change the IP address on the container network interface. 

Importing containers from a server with a third-party control panel


There are 2 variants to import containers from servers with other control panels: 

  • install VMmanager OVZ locally on the source server;
  • install VMmanager OVZ on a separate server and add the source server a cluster node.

Complete the following steps before you start:

  1. Install VMmanager OVZ on the local or a separate server
  2. Disable or uninstall the  control panel;
  3. Create the following objects in VMmanager OVZ:
    1. Cluster nodes. Connect all the servers from which you want to import virtual machines. 
    2. A user who will be the owner of the virtual machines; otherwise a new user will be created for each container.
    3. Networks. In the IP addresses management module or in IPmanager create networks corresponding to the IP addresses of your container; network type is "public".

Execute the command to start importing the local containers. Container identifiers  (CTID) will be changed:

/usr/local/mgr5/sbin/mgrctl -m vemgr import.local user=user_id elid=CTID hostnode=id|all
BASH

Parameters of the import.local function:

  • user [optional ] identifier of the existing user who will be the owner all of the imported containers. If this parameter is not specified, a new user will be created for each container. The user identifier can be found in the list of users in the id column;
  • elid [optional] container identifier [CTID]. If this parameter is specified, only one container will be imported; otherwise, all containers will be imported;
  • hostnode [optional] identifier of the cluster node (it can be found in the cluster nodes module in the id column ) from which you want to import containers, or all if you want to import from all of the cluster nodes; if the parameter is not specified, import from the local cluster node will be made.


The command output must be empty. Make sure there are no errors in the import log. The command output must be empty: 

grep "WARNING Skip" /usr/local/mgr5/var/vemgr.log
BASH