Move OpenVZ Containers Between Servers

The vzmigrate command in openvz allows you to migrate a virtual container from one openvz server to another. Depending on the hardware and a few other factors, this can potentially be done online, otherwise there are options which include a restart but minimal downtime.

On openvz01.example.motorrobot.net, we have a container with the CTID 101 and hostname www01.example.motorrobot.net. We are logged into openvz01 and wish to migrate this to openvz02.example.motorrobot.net. We want to remove the container from openvz01 after a successful migration, and so we use the -r flag and say yes. We also have the same hardware on both openvz servers, so we’ll add –online to perform the migration without downtime to the container.

So migrate container with CTID 101 to openvz02.example.motorrobot.net without downtime and remove the container from openvz01 when completed.

vzmigrate -r yes --online openvz02.example.motorrobot.net 101