Reinstalling an OpenVZ Master
From SolusVM
Contents |
Installing needed packages
yum install exim vzdump ncftp
Copying the SolusVM database
See this http://wiki.solusvm.com/index.php/Database_Dump_Script or make a backup of the database with one of the in panel database backup tools.
If your database dump is on the server you can ftp it with the following command:
ncftpput -u USERNAME -p PASSWORD FTPSERVERIP /path/on/ftp/server /path/to/database/dump
You can also copy it to your local system if you prefer.
- Always check the file has uploaded correctly.
You will also need a copy of your encryption key from the solusvm.conf (/usr/local/solusvm/includes/solusvm.conf) The format is <DATABASENAME>:<USER>:<PASSWORD>:<HOST>:<ENCRYPTION KEY>
If in doubt just copy the whole file to ftp or to your local system for safe keeping.
Backing up the Virtual Servers
If your master has virtual servers you can back them up with vzdump. You will need to know each container id, you can get this by issueing this command in ssh:
[root@master ~]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
107 - running 109.169.51.15 api.test.com
109 - stopped 109.169.51.13 apitest1.com
110 - running 1.1.1.1 apitest2.com
Now you know the CTID of each vps you can back them up:
vzdump --compress CTID
example:
[root@master ~]# vzdump --compress 107 INFO: Starting new backup job - vzdump --compress 107 INFO: Starting Backup of VM 107 (openvz) INFO: status = CTID 107 exist unmounted down INFO: creating archive '/vz/dump/vzdump-107.dat' (/vz/private/107) INFO: Total bytes written: 812595200 (775MiB, 7.4MiB/s) INFO: file size 151MB INFO: Finished Backup of VM 107 (00:01:47) [root@master ~]#
You can see that the dump has been put in the /vz/dump/ folder, so all we need to do is upload it to the ftp server:
ncftpput -u USERNAME -p PASSWORD FTPSERVERIP /path/on/ftp/server/ /vz/dump/vzdump-107.tgz
Misc Backups
You may also consider backing up the template folders on the master. the locations for each virtualization type are listed below:
- Xen Templates => /home/solusvm/xen/template/
- Xen ISO's => /home/solusvm/xen/iso/
- KVM ISO's => /home/solusvm/xen/iso/
- OpenVZ Templates => /vz/template/cache/
Reinstalling the Operating System
You can now reinstall the operationg system.
Install SolusVM
Once you have reinstalled the OS, you then need to install the master in the normal way with the installer.
Restoring the SolusVM Database
Upload the database backup to the new master or download it from the FTP server.
You can get the new database details from /usr/local/solusvm/includes/solusvm.conf, they are seperated with a :
example: <DATABASENAME>:<USER>:<PASSWORD>:<HOST>:<the key is the last entry>
IMPORTANT You now need to replace the encryption key in the new solusvm.conf with the old encryption key you backed up. (See the layout above).
Once thats done you can restore the database:
/usr/bin/mysql --user=USER --password=PASSWORD DATABASENAME < database.sql
You should now beable to login to the master with your old login details.
Restoring the Virtual Servers
Download each backup from the ftp server:
ncftpget -u USERNAME -p PASSWORD FTPSERVERIP /vz/dump/ /path/on/ftp/server/vzdump-107.tgz
Once the backup(s) are downloaded you can restore each container:
vzdump --restore /vz/dump/vzdump-CTID.tgz CTID
example:
[root@master ~]# vzdump --restore /vz/dump/vzdump-107.tgz 107 INFO: restore openvz image 'vzdump-107.tgz' using ID 107 INFO: extracting archive 'vzdump-107.tgz' INFO: extracting configuration to '/etc/vz/conf/107.conf' INFO: restore successful
Thats it all done!
