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 firstname.lastname@example.org:/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
Following steps would help you to do scp, ssh & rsync without prompting for password:
1. On Host A where you run scp/ssh/rsync command, run the following command:
$ ssh-keygen -t rsa
This will prompt a passphrase. After pressing enter key it’ll generate a private and a public key. Public key is saved at ~/.ssh/ by default.
2. Transfer id_rsa.pub file to Host B using scp or ftp.
3. On Host B, login as remote user and copy the contents of id_rsa.pub to ~/.ssh/authorized_keys using the following command:
$ cat id_rsa.pub >>~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys
4. Thats’ all, Now you can run scp, ssh and rsync command without prompting for password.
5. Note that ssh by default does not allow root to log in. This has to be explicitly enabled on Host B. This can be done by editing /etc/ssh/sshd_config and changing the option of PermitRootLoginfrom no to yes. Don’t forget to restart sshd so that it reads the modified config file. Do this only if you want to use the root login.
$service apache2 restart
[....] Starting web server: apache2(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
In order to solve the above issue, type following on your console
fuser -k -n tcp 80
Http Error 0 is a very common error that occurs in Drupal. There are many reasons behind this error.
One of the way to resolve this error is to append the following line in this file : /etc/apache2/mods-available/fcgi.conf
Increase the number value of the MaxRequestLen until the error stops to continue.