Chapter 9. Backing Up and Restoring the Red Hat Storage Console

The Red Hat Storage Console is key part of a Red Hat Storage environment which is responsible for maintaining important information about the environment. It is recommended that the Red Hat Storage Console be backed up so that recovering from unforeseen events is as simple and fast as possible.

9.1. Backup and Restore the rhsc Postgres Database

Information about the Red Hat Storge environment is kept in a Postgres database, including information about servers, users, and more. The rhsc database is a key component of the Red Hat Storage environment so it is highly recommended that regular backups of the database be taken.
While these procedures specifically mention the rhsc 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 rhsc_history database.

9.1.1. Backing up Databases in Red Hat Storage

Procedure 9.1. To backup the rhsc database:

  1. From the terminal on the Red Hat Storage Console server as root use the pg_dump command to dump the rhsc database:
    # pg_dump -C -E UTF8 --column-inserts --disable-dollar-quoting --disable-triggers -U postgres --format=p -f /usr/share/rhsc/db-backups/dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql rhsc
    
    The output file name and directory are user specified, /usr/share/rhsc/db-backups/dump_RHSCDB_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 rhsc database backup with ssh keys, a script, and a cron job.

    Example 9.1. Example rhsc 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/rhsc/db-backups/dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql rhsc;
    scp /usr/share/rhsc/db-backups/dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql $BACKUPUSER@$BACKUPSERVER:$BACKUPDIRECTORY;
    

Now that you have created a backup of the rhsc database using the pg_dump, you can use the .sql file you created to restore the rhsc database.

9.1.2. Restoring Databases in Red Hat Storage

Procedure 9.2. To restore the rhsc 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 Storage Console server as root:
    # psql -U postgres -d rhevm -W -f /usr/share/rhsc/db-backups/dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql
    Substitute the name of the .sql file being restored for dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql.
    1. If you are required to remove the existing rhsc database to create a new one, first stop the jbossas service using the service jbossas stop command.
    2. When you have created the new rhsc database and imported database backup file, start the jbossas service using the service jbossas start.