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.
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.
Procedure 9.1. To backup the rhsc database:
- From the terminal on the Red Hat Storage Console server as root use the
pg_dumpcommand to dump therhscdatabase:# 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"`.sqlrhscThe output file name and directory are user specified,/usr/share/rhsc/db-backups/dump_RHSCDB_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
rhscdatabase backup with ssh keys, a script, and a cron job.Example 9.1. Example
rhscPostgres 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/rhsc/db-backups/dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sqlrhsc; 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.
Procedure 9.2. To restore the rhsc database:
- To restore a
.sqlthat was created using thepg_dumpcommand, use thepsqlinteractive shell. From the terminal on the Red Hat Storage Console server as root:# psql -U postgres -d rhevm -W -f
Substitute the name of the/usr/share/rhsc/db-backups/dump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql.sqlfile being restored fordump_RHSCDB_BACKUP_`date "+%Y%m%d_%R"`.sql.- If you are required to remove the existing
rhscdatabase to create a new one, first stop the jbossas service using theservice jbossas stopcommand. - When you have created the new
rhscdatabase and imported database backup file, start the jbossas service using theservice jbossas start.