Dino Geek, try to help you

How to migrate an OpenVZ container to another server without downtime?


Migrating an OpenVZ container to another server without downtime can be a challenge, but it’s achievable. Here are the steps:

Before you start, you need to have the same OS template that you used to create your original OpenVZ container available on the destination server. If not, you need to download and install it.

1. Prepare the Destination Server:

- Firstly, install OpenVZ on the new server and start the service.
- Make sure you have installed the same OS template that was used for the original OpenVZ container.

1. Synchronize the Files:

- The next step is to sync the container’s files between the two servers. It’s a good practice to stop or slow down any services in the container that generate constant changes during this sync.

- The rsync command will help a lot. Run:

rsync -avz —progress —numeric-ids -e ‘ssh -p 22’ /vz/private/{CT ID} user@destination:/vz/private/

Replace “{CT ID}” with the ID of your container, and “user@destination” with the appropriate user and IP for the destination server.

- After the first rsync is complete, do a second pass with the container stopped to get any files that changed or were missed. First stop the container:

`vzctl stop {CT ID}`

- Then run the rsync command again.

1. Setting Up the New Container:

- Now, in the new server, we need to create a new container with the same ID as the old container.

vzctl create {CT ID} —ostemplate {template} —config {configname}

- Replace “{template}” with the name of your OS template and “{configname}” with the name of your desired config.

- Then register the private area (where the data of the containers is stored) in the container’s configuration:

vzctl set {CT ID} —private /vz/private/{CT ID} —save

1. Migrate the IP:

- Before stopping the original container to switch over to the new one, make sure that you have migrated the IP. Remove the IPs from the old container:

vzctl set {CT ID} —ipdel all —save

- And add them to the new container:

vzctl set {CT ID} —ipadd {IP} —save

1. Start the Container:

- Now, you can start the new container:

vzctl start {CT ID}

You should now be able to ssh to the new container and check everything is working as expected. If everything is fine, then you have successfully migrated the OpenVZ container.

Note: Always have a recent backup before any migration process is attempted. Also ensure that the new server is similarly capable or better than your old server to avoid underperformance or other issues.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use