Show Table of Contents
3.2. Backing up an Embedded Database
Red Hat Satellite provides a specialized command-line utility to assist with embedded database management tasks. The
db-control command provides features to create, verify, and restore backups, to obtain database status information and to restart the database when necessary. See the db-control manual page (man db-control) for a full listing of the features available.
The following sections are demonstrate how to create, verify, and restore Red Hat Satellite embedded and managed databases.
3.2.1. Performing Online Database Backups
Red Hat Satellite Server 5 contains functionality that enables online backups of your database, without the need to stop the Satellite Server. Additions to the existing
db-control command make this functionality possible.
Three new options have been added to the
db-control command:
online-backup FILENAME:Performs an online backup of the Satellite database (embedded PostgreSQL only).reset-password:Resets the user password and unlocks the account.restore DIRECTORY | FILENAME:Restores the database from either:- An offline backup taken by
db-controland saved in the DIRECTORY directory. The database must be stopped for both thebackupbackupandrestoreoperations in order to run successfully. - An online backup taken by
db-controland saved as FILENAME. The database itself must be running for both theonline-backuponline-backupandrestoreoperations in order to run successfully, but all other Satellite services must be stopped.
3.2.1.1. Performing an Online Backup
To create an online backup of an embedded Red Hat Satellite 5 server database, change to the root user, and run the following command. Replace the
FILENAME option with the full path to the backup file that you want to create. This location needs to be writable by the PostgreSQL user:
# db-control online-backup FILENAMENote
There is no need to stop either the database or the Satellite services to perform an online backup.
3.2.1.2. Restoring a Database from an Online Backup
Use the
db-control restore FILENAME command to restore an embedded database from a backup created using the db-control online-backup command. Before you restore a database, you need to shut down all Satellite services except the database itself.
Procedure 3.1. To Restore a Database from an Online Backup:
- Change to the root user, and run the following command to stop all Satellite services except the database:
# rhn-satellitestop--exclude=rh-postgresql95-postgresql - Run the following command to restore the database. Replace the
FILENAMEoption with the full path to the backup file created with thedb-controlcommand:online-backup# db-controlrestoreFILENAME - After the restoration is complete, run the following command to restart the database and all related services:
# rhn-satellitestart
3.2.2. Performing Offline Database Backups
Red Hat Satellite Server 5 provides the ability to perform online backup and restore operations. Red Hat recommends that you continue to perform offline backups during monthly or quarterly maintenance windows.
3.2.2.1. Performing an Offline Backup
The following procedure describes how to back up an embedded Red Hat Satellite server database.
Procedure 3.2. To Create an Offline Backup:
- Change to the root user, and run the following command to stop the Satellite server:
# rhn-satellite stop - Run the following command to create the backup:
# db-controlbackup DIRECTORYReplace DIRECTORY with the absolute path to the location where you want to store your database backup. This process will take several minutes. - When the backup is complete, run the following command to restart the Satellite server:
# rhn-satellite start - Copy the backup to another system using rsync or another file-transfer utility. Red Hat strongly recommends scheduling the backup process automatically using cron jobs. For instance, back up the system at 03:00 and then copy the backup to the separate repository (partition, disk, or system) at 06:00.
3.2.2.2. Verifying the Backup
Backing up the embedded database is useful only if you can ensure the integrity of the resulting backup. There are two approaches to this integrity check; you can examine the backup to check its time stamp and identify any missing files, or you can verify the backup, which involves a more thorough inspection and validation of the md5sum of each file in the backup. The first approach is quicker, but the second provides more thorough validation.
To examine the backup, run the following command as root:
# db-control examine BACKUP_FILE
To verify the backup, run the following command as root:
# db-control verify BACKUP_FILE
If the verification is successful, you can safely restore the database from the BACKUP_FILE directory.
Note
Users of external databases should also perform periodic backups. Consult your external database administrator for more information about supported backup procedures.
3.2.2.3. Restoring the Database
Use the
db-control restore command to restore embedded databases from backup. Before you attempt to restore a database, you need to shut down the database and any related services.
Procedure 3.3. To Restore an Embedded Database from a Backup:
- Run the following command to stop all of the Red Hat Satellite services:
# rhn-satellitestop - Run the following command, including the directory containing the backup, to begin the restoration. Ensure that you replace directory with the absolute path to the location that contains the backup. This process will verify the contents of the backup before restoring the database. The process will take several minutes.
# db-controlrestore directoryThis not only restores the embedded database but first verifies the contents of the backup directory using checksums. - After the restoration is complete, restart the database and related services:
# rhn-satellitestart - Regardless of whether you are backing up an external or embedded database, when the database is restored from a backup, you should schedule the restoration of search indexes the next time the
rhn-searchservice is started:# service rhn-searchcleanindex

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.