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-control backup and saved in the DIRECTORY directory. The database must be stopped for both the backup and restore operations in order to run successfully.
    • An online backup taken by db-control online-backup and saved as FILENAME. The database itself must be running for both the online-backup and restore operations 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 FILENAME

Note

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:

  1. Change to the root user, and run the following command to stop all Satellite services except the database:
    # rhn-satellite stop --exclude=rh-postgresql95-postgresql
  2. Run the following command to restore the database. Replace the FILENAME option with the full path to the backup file created with the db-control online-backup command:
    # db-control restore FILENAME
  3. After the restoration is complete, run the following command to restart the database and all related services:
    # rhn-satellite start

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:

  1. Change to the root user, and run the following command to stop the Satellite server:
    # rhn-satellite stop
  2. Run the following command to create the backup:
    # db-control backup DIRECTORY
    Replace DIRECTORY with the absolute path to the location where you want to store your database backup. This process will take several minutes.
  3. When the backup is complete, run the following command to restart the Satellite server:
    # rhn-satellite start
  4. 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:

  1. Run the following command to stop all of the Red Hat Satellite services:
    # rhn-satellite stop
  2. 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-control restore directory
    This not only restores the embedded database but first verifies the contents of the backup directory using checksums.
  3. After the restoration is complete, restart the database and related services:
    # rhn-satellite start
  4. 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-search service is started:
    # service rhn-search cleanindex
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.