This topic is about sharing information on how to backup/migrate OpenVZ VPS Node / server, optionally with HyperVM control panel.

Follow all instructions on this website on your own risk, you can loose your data when doing commands you dont understand.

1) Tutorial: New HyperVM server setup:

2) Tutorial: HyperVM settings/config/database backup/restore

3) Tutorial: How to backup all OpenVZ/HyperVM/Proxmox.. VMs (VPSs):

Rest of this post is crap and not veriffied information. It is not recommended anyone to use it.

Sumary of the whole server backup/restore process (not important to read)
According to above manuals, to restore whole OpenVZ system, one can: 1) Install hyperVM server; 2) restore hypervm configuration (mysql file); 3) restore virtual machines 4) go thru HyperVM VMs and add new IPs to them + start them. Some service configurations like DNS server of a VPSes may need replacing old IP by a new one. Maybe good idea would be running search on whole VPS in files, to lookup where the old VPS IP is and replace by new IP. If some domains points to a VPS, also IP should need changing in domain nameservers in domain registar (Godaddy, Namecheap etc). If you have any ideas on next things needed to be backup, or way to backup/restore whole host node easilly, please kindly share it. Thank you


OpenVZ+HyperVM migration process - option 1:

A) Install CentOS 5.x 64bit; HyperVM master to new server according to "New HyperVM server setup" tutorial
B) Then start migrating OpenVZ VMs using this tutorial or alternativelly this one (vzmigrate is used on both). Also a .sh script can be used to migrate all VMs at once:
for CT in $(vzlist -H -o veid); do vzmigrate -v --remove-area no --online --keep-dst --ssh="-p 22" YOURNEWSERVERIPHERE $CT; done
(can use only after SSH pub. key is setup according to previously mentioned tutorial.) IMPORTANT: after migration, VM config file in /etc/vz/conf/VMID.conf get renamed to VMID.conf.migrated which can cause VM go offline on old node!!. (vzmigrate troubleshooting? read here)
C) During the migration open another console window on the old server and backup HyperVM mysql (configuration) according to "HyperVM configuration - How to backup/restore HyperVM settings/config/database" tutorial.
D) Backup default hypervm mysql on new server and restore mysql from old server on the new server according to manual mentioned in step C (it can be needed to replace old server IP in mysql file to a new server IP. Example command to replace:
find /root -name 'hypervmbackup.sql' -type f -print0 | xargs -0 sed -i 's|oldserverip|newserverip|g'

So new server has os, openvz, hypervm, restored mysql and migration in progress or finished..

E) On the new server, add new IP pools in HyperVM web control panel, on list of VMs take screenshot or copy list to take a note of old IPs, then remove one by one old IPs and assign new ones.

F) Once vzmigrate is complete (step B), one can veriffy VM is working on a new server. On new server "Hard refresh" list of VMs on VMs page in HyperVM. The red ones or with cross icons you can A) delete and try migrating from HyperVM (hypervm/vms/vm name/Live migrate - you need to have added a Server, so you can select it here), option B) create OStempalte on old server, copy it to new server and restore there.

G) Replace old assigned IPs in VPS files by new one. Point domain nameservers to a new IPs

OpenVZ+HyperVM migration process - option 2:

A) install os, hypervm master on new server (according to tutorial linked in point A of the previous process)
B) Log into your old Master: in HyperVM, Servers tab -> localhost -> Save VPS Data
C) Log into your new Master: in HyperVM, Servers tab -> Servers -> Add Server. Add your Old Master to the New Master.
D) Log into your new Master: in HyperVM, Servers tab -> Servers, Click the entry you just added Old Master as.. Inside there, click Import HyperVM VPS.

OpenVZ+HyperVM migration process - option 3:

Migration from HyperVM method #2:
Old server HyperVM / VMs / VM name / Create OStemplate
transfer tamplate from old server to new, example:
scp -P 22 /vz/template/cache/centos-5-x86_64-my660vmbackup root@NEWVPSHOSTSERVERIP:/vz/template/cache
Backup old server HyperVM mysql, replace old server ips by new server ips in it and restore on new server (you may need to reset password on old server if you dont know it). Then rebuild each VM from OS template you transfered. (slow way if nothing else works)

Full process of changing OpenVZ, HyperVM server - option 4 (with commands):

# Install OS, HyperVM according to:
# backup mysql (hypervm config)
cd /root
mysqldump -u root -pMYSQLPASSWORDHERE hypervm1_0 > newserverdb.sql

# backup mysql (hypervm config)
cd /root
mysqldump -u root -pMYSQLPASSWORDHERE hypervm1_0 > oldserverdb.sql
# make sure its correct database
tail oldserverdb.sql;ls -lh oldserverdb.sql
# copy it to a new server
scp -P 22 oldserverdb.sql root@NEWSERVERIPHERE:/root
# generate public key for ssh access to new server
chmod a+x
# try to migrate one VM for testing purposes
vzmigrate --remove-area no --online --ssh="-p 22" NEWVPSHOSTSERVERIP VMID
# if succeeded, create script for migrating all VMs
touch;chmod +x;vi;
# paste following code to the script and save (read "man vzmigrate" to learn, if you have issues read here) following code is an oneliner. IMPORTANT: after migration, VM config file in /etc/vz/conf/VMID.conf get renamed to VMID.conf.migrated which can cause VM go offline on old node!!
for CT in $(vzlist -H -o veid); do vzmigrate -v --remove-area no --online --keep-dst --ssh="-p 22" YOURNEWSERVERIPHERE $CT; done
# install "screen" software to keep migration running on background
yum install screen
screen -t migration
# run migration script
# Keyboard shortcut Ctrl+a and then key "d" to detach the screen

# duplicate mysql backup file we copied from older server and replace old server ip by new server ip in the mysql file
cp oldserverdb.sql oldserverdb_modiffied.sql
find /root -name 'oldserverdb_modiffied.sql' -type f -print0 | xargs -0 sed -i 's|OLDSERVERIP|NEWSERVERIP|g'
# restore modiffied mysql backup file
mysql -u root -pMYSQLPASSWORDHERE hypervm1_0 < oldserverdb_modiffied.sql
(if you dont know the password here is how to reset)
# add new IP pool in HyperVM web panel (the ips assigned to the new server) so we can use them on VMs

# check migration status, attach "screen" window
screen -ls
# once migration done, can continue to next step (if used vzmigrate, VMs .conf can be renamed to *.migrated so old server VMs stop working

# copy list of VMs and their oldserver IPs for future reference, example output it to file "oldvzlist"
vzlist > oldvzlist;cat oldvzlist
# from HyperVM remove & assign new IPs to VMs one by one

Another things needed 2do during before migration in my case:
mv /vz /home/vz;
ln -s /home/vz /vz
ln -s /vz/root /home/vps
HyperVM/Home path (may delete /home/vps)
Enable IPv6:
doing "modprobe tun" and similar

My resulting tutorial:

- make sure /etc/cron.daily/vmsbackup script (vzdump) was run on old server around 24 hours before migration to backup all VMs
- if not run, run it in a screen window (screen; sh scriptpath;ctrl+a + d to detach;screen -r to restore;exit to kill)

1) on old server: open new session and run backup script ./backup/manualbackup
2) on new server: run ./backup/hypervminstall script to setup hypervm and openvz
3) on new server: extract backup file located in "/" and run restore script located in ./backup/manualbackup
4) on old server: after step 3 is complete and new server rebooted, run ./root/vzmigrate for each VM one by one or all at once
5) after a VM is migrated, run /root/vzdumprestore to fix VMs DNS and change IPs
6) change nameservers on domain registrar so they point to new VM IP
7) add new server to whmcs billing system, in new server hypervm edit some VM uplink speed so all vm traffic limitting values are propagated into /usr/local/lxlabs/hypervm/etc/