Well, I am not that sound in playing with the tools of openvz but through the assistance of professionals, I came to learn how to take backup of openvz and restore it in another proxmox virtual environment. In order to understand this tutorial, you must have a little knowledge of Linux and its basic commands. The following steps more or less clearifies the process:
- Login to your proxmox via root.
- Check whether there is sufficient space to take backup. Use the command below to check the available space on the system:
moon:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/pve-root 95G 15G 76G 16% /
tmpfs 16G 0 16G 0% /lib/init/rw
udev 10M 632K 9.4M 7% /dev
tmpfs 16G 0 16G 0% /dev/shm
/dev/mapper/pve-data 723G 272G 452G 38% /var/lib/vz
/dev/sda1 504M 44M 435M 10% /boot
- In order to list out the virtual machines type the following command:
CTID NPROC STATUS IP_ADDR HOSTNAME
101 67 running 10.10.10.110 hindi-website.example.com
103 206 running 10.10.10.251 maincopy.example.com
201 92 running 10.10.10.106 engsecondary.example.com
240 64 running 10.10.10.108 wsdb-backup.example.com
242 78 running 10.10.10.107 hi-secondary.example.com
410 109 running 10.10.10.104 rc.example.com
- Note down the CTID for which you are taking the backup. CTID is an identifier which uniquily represents the respective virtual machine.
- Follow the command below to take the backup of the virtual machine:
moon:~# sudo vzdump –dumpdir /var/lib/vz/dump/ 103 –suspend –compress
The above command takes a complete backup of the virtual machine whose CTID is 103 at the location /var/lib/vz/dump/. The backup process will take approximately an hour to complete. In order to confirm the successfull backup change the directory to /var/lib/vz/dump/ and execute the command ls or dir. Two files are generated prefixed by vzdump-openvz-*.
- Copy the backup to another proxmox using the following command:
moon:~# scp vzdump-openvz-103-2014_06_24-17_22_53.tgz email@example.com:/var/lib/vz/dump/
- In order to restore, first of all login to your proxmox via GUI.
- Delete the virtual machine if there is insufficient space or make some space to restore the backup.
- Now, Login to your proxmox using ssh or putty. Change your directory to /var/lib/vz/dump/ (location of the backup) . Execute the following command:
earth:~# vzrestore vzdump-openvz-103-2014_06_24-17_22_53.tgz 103
The above command will restore the backup creating a complete new virtual machine. It takes approximately an hour to complete the process.
- Login to your proxmox via GUI. A new virtual machine will be visible. Before starting the machine modify the IP Address in order to prevent the IP conflict.
- If the macnine contains MySQL binded with the IP then modify the IP from the file /etc/mysql/my.conf