The Red Hat Enterprise Virtualization Manager is key part of a Red Hat Enterprise Virtualization environment which is responsible for maintaining important information about the environment. It is recommended that the Red Hat Enterprise Virtualization Manager be backed up so that recovering from unforeseen events is as simple and fast as possible.
Information about the Red Hat Enterprise Virtualization environment is kept in a Postgres database, including information about virtual machines, hosts, networks, storage, users, and more. The
rhevm database is a key component of the Red Hat Enterprise Virtualization environment so it is highly recommended that regular backups of the database be taken.
While these procedures specifically mention the
rhevm database, they should be repeated for each database being backed up. For example, the same procedures can be used to back up and restore the rhevm_history database.
Procedure 15.1. To backup the rhevm database:
- From the terminal on the Red Hat Enterprise Virtualization Manager server as root use the
pg_dumpcommand to dump therhevmdatabase:# pg_dump -C -E UTF8 --column-inserts --disable-dollar-quoting --disable-triggers -U postgres --format=p -f
/usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sqlrhevmThe output file name and directory are user specified,/usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sqlshould be replaced with a desired location and file name. - Consider mounting a remote backup location locally and using the
pg_dumpto write the database backup file directly to the mounted remote location. - Copy the
.sqlfile to a remote backup location. This can be accomplished using scp, rsync, or some other third party back up tool. - Consider automating the
rhevmdatabase backup with ssh keys, a script, and a cron job.Example 15.1. Example
rhevmPostgres database backup scriptThis script presumes that an ssh key has been set up for the user that executes the script. The public key must then be added to the remote users~/.ssh/authorized_hostsusing thessh-copy-id BACKUPUSER@BACKUPDIRECTORYcommand so that thescpcommand can be done without a password.#!/bin/sh # Enter appropriate values for the BACKUPUSER, BACKUPSERVER, and BACKUPDIRECTORY variables. DATE = `date "+%Y%m%d_%R"`; BACKUPUSER = ; BACKUPSERVER = ; BACKUPDIRECTORY = ; # pg_dump -C -E UTF8 --column-inserts --disable-dollar-quoting --disable-triggers -U postgres --format=p -f
/usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sqlrhevm; scp/usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sql$BACKUPUSER@$BACKUPSERVER:$BACKUPDIRECTORY;
Now that you have created a backup of the
rhevm database using the pg_dump, you can use the .sql file you created to restore the rhevm database.
Procedure 15.2. To restore the rhevm database:
- To restore a
.sqlthat was created using thepg_dumpcommand, use thepsqlinteractive shell. From the terminal on the Red Hat Enterprise Virtualization Manager server as root:# psql -U postgres -d rhevm -W -f
Substitute the name of the/usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sql.sqlfile being restored fordump_RHEVDB_BACKUP_CURRENT_DATE.- If you are required to remove the existing
rhevmdatabase to create a new one, first stop the jbossas service using theservice jbossas stopcommand. - When you have created the new
rhevmdatabase and imported database backup file, start the jbossas service using theservice jbossas start.