How to Backup OpenVZ containers (VM’s) using vzdump on Centos / RHEL

Date Posted : 10-10-2018

OpenVZ is a linux based Kernel virtualization technology developed by SWSoft for its commercial product Virtuozzo.In this article we are going to learn about how to backup VM’s which are running under Hardware node.

Prerequisites:

  • Virtualization setup (one or more VM’s running under Hardware node) under Virtuozzo.

Introduction:

We may aware that,vzdump is not included in the openvz repository for CentOS/RHEL.If you need to use vzdump, you have to download its source and compile it yourself. Fortunately,SolusVM includes it in its repo,which can be used on your hardware node if SolusVM not installed.After successful installation we can able to backup your desired virtual machine at your desired location.

I.Installation of VZdump

Step 1 : Create the file ‘solusvm.repo’ and paste the below mentioned content in the path /etc/yum.repos.d 

cd /etc/yum.repos.d

touch solusvm.repo

vi solusvm.repo

Content :

[soluslabs]
name=Soluslab Repo
#baseurl=http://repo.soluslabs.com/centos/$releasever/os/$basearch
mirrorlist=http://repo.soluslabs.com/centos/mirrors-soluslabs
gpgcheck=0
enabled=1

Step 2 : Install vzdump from repo into the server

yum install vzdump

II.Backup desired VM’s using  vzdump command

After successful installation of vzdump command.We are free to take backup of the desired VM’s.Make sure you  have login as root user into Hardware node with full privileges.

Step 1 : List the current VM’s, which are configured under Hardware node.

vzlist -a

output will be similar to this: (this shows the current status of VM)

#vzlist -a
 CTID  NPROC   STATUS    IP_ADDR         HOSTNAME
 101   338    running  192.168.0.101  server1.example.com
 102   -      stopped  192.168.0.102  server2.example.com
 103   -      stopped  192.168.0.103  server3.example.com

Step 2 : Locate the directory to store VM’s backup.

Now create the directory where the backup will be automatically stored and provide the permission to access the directory. I will use this path /home/backup for illustration.You’re free to use any directory,just make sure that you have enough space in that particular directory where you’ll store the VM backup.

mkdir /home/backup

chmod 700 /home/backup

chown root:root /home/backup

Step 3 : How to create backup for single VM

For this example, I’m going to use VM ‘192.168.0.101’ whose CTID is ‘101’

vzdump --compress --dumpdir /home/backup 101

the option –compress tweak the vzdump to store the backup as tar.gz format inorder to save the memory space.

Step 4 : How to create backup for all the VM’s which are configured under one hardware node.

vzdump --compress --dumpdir /home/backup --all

Add-on tip

>> How to restore the one’s VM backup into another VM.

The backup we created using vzdump can be restored with the vzrestore command.For example, restoring the VM 101 from backup to another VM whose CTID is 103

vzrestore /home/backup/vzdump-101.tgz 103

For more info regarding vzrestore options, kindly explore

man vzrestore

 

I hope it worked safely and successfully. Leave comments for any queries!

 

 

 

 

 

Leave a Reply