Chapter 15. Backing Up and Restoring the Red Hat Enterprise Virtualization Manager.

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.

15.1. Backup and Restore the rhevm Postgres Database

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.

15.1.1. Backing up Databases in Red Hat Enterprise Virtualization

Procedure 15.1. To backup the rhevm database:

  1. From the terminal on the Red Hat Enterprise Virtualization Manager server as root use the pg_dump command to dump the rhevm database:
    # 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"`.sql rhevm
    
    The output file name and directory are user specified, /usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sql should be replaced with a desired location and file name.
  2. Consider mounting a remote backup location locally and using the pg_dump to write the database backup file directly to the mounted remote location.
  3. Copy the .sql file to a remote backup location. This can be accomplished using scp, rsync, or some other third party back up tool.
  4. Consider automating the rhevm database backup with ssh keys, a script, and a cron job.

    Example 15.1. Example rhevm Postgres database backup script

    This 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_hosts using the ssh-copy-id BACKUPUSER@BACKUPDIRECTORY command so that the scp command 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"`.sql rhevm;
    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.

15.1.2. Restoring Databases in Red Hat Enterprise Virtualization

Procedure 15.2. To restore the rhevm database:

  • To restore a .sql that was created using the pg_dump command, use the psql interactive shell. From the terminal on the Red Hat Enterprise Virtualization Manager server as root:
    # psql -U postgres -d rhevm -W -f /usr/share/rhevm/db-backups/dump_RHEVDB_BACKUP_`date "+%Y%m%d_%R"`.sql
    Substitute the name of the .sql file being restored for dump_RHEVDB_BACKUP_CURRENT_DATE.
    1. If you are required to remove the existing rhevm database to create a new one, first stop the jbossas service using the service jbossas stop command.
    2. When you have created the new rhevm database and imported database backup file, start the jbossas service using the service jbossas start.