Search

Chapter 18. Backup and Disaster Recovery

download PDF
This chapter describes the minimum and typical backup and restore procedures required to ensure continuity of your Red Hat Satellite deployment and associated data in the event of a disaster. If your deployment uses custom configurations you should take these into account when planning your backup and disaster recovery policy.

18.1. Backing up Red Hat Satellite

This section describes how to prepare and back up your Red Hat Satellite Server to facilitate recovery in the event of disaster. This example uses the /backup directory as the target directory for backup archives, and is described in several parts:
  • Preparing the backup location and backing up configuration and data files
  • Backing up the repositories
  • Backing up the databases
  • Verifying the backup

Note

If SELinux is enabled and in enforcing mode, ensure that any local content requiring synchronization is labeled with "httpd_sys_content_t".

Procedure 18.1. To Prepare the Backup Location and Back up Configuration and Data Files:

  1. Prepare your backup location:
    # umask 0027
    # export BDIR=/backup
    # mkdir $BDIR
    # chgrp postgres $BDIR
    # chmod 770 $BDIR
    # cd $BDIR
    
  2. Back up the configuration and data files:
    # tar --selinux -czvf config_files.tar.gz \
    /etc/katello \
    /etc/elasticsearch \
    /etc/candlepin \
    /etc/pulp \
    /etc/pki/katello \
    /etc/pki/pulp \
    /etc/qpidd.conf \
    /etc/sysconfig/katello \
    /etc/sysconfig/elasticsearch \
    /root/ssl-build \
    /var/www/html/pub/*
    
    # tar --selinux -czvf elastic_data.tar.gz /var/lib/elasticsearch
Backing up Satellite Repositories

The RPM files in repositories already use compression and cannot be compressed any further. Therefore, depending on instance size, the resulting backup archive (pulp_data.tar) can grow quite large. Ensure you have sufficient space to store the resulting file.

There are two options for backing up repositories: online backup; and offline backup.

Procedure 18.2. To Perform an Online Repository Backup:

  • Run the following commands to perform a checksum of all time stamps, back up the repository, and perform the checksum again.
    # find /var/lib/pulp -printf '%T@\n' | md5sum
    # tar --selinux -cvf pulp_data.tar /var/lib/pulp /var/www/pub
    # find /var/lib/pulp -printf '%T@\n' | md5sum
    If the checksums match, the online backup is correct and usable. If the checksums do not match, perform the repository backup again.

    Note

    You can use the rsync command to speed up file copying. This can help to ensure the checksums match.

Procedure 18.3. To Perform an Offline Repository Backup:

  • Run the following commands to stop the required services, perform the backup, and restart the services:
    # katello-service stop
    # tar --selinux -cvf pulp_data.tar /var/lib/pulp /var/www/pub
    # katello-service start

    Note

    While the katello-service is stopped, Red Hat Satellite and the yum clients will be unable to maintain a connection. Any repository actions performed on Red Hat Satellite will fail during this period.
Backing up the Databases

You can perform either online or offline database backups. You do not need to do both. Offline backups require that the Satellite Server be completely inactive.

Warning

Red Hat Satellite must be completely inactive to do an offline backup. Following this procedure while Satellite is running may result in corrupted data.
This method archives all data from the PostgreSQL and MongoDB databases. Red Hat recommends that you perform this backup during maintenance periods.

Procedure 18.4. To Perform a Complete Offline Database Backup:

  1. Ensure the Satellite Server is completely stopped:
    # katello-service stop
  2. Run the following commands to back up the PostgreSQL and MongoDB databases:
    # tar --selinux -czvf mongo_data.tar.gz /var/lib/mongodb
    # tar --selinux -czvf pgsql_data.tar.gz /var/lib/pgsql/data/
    
  3. Restart the required services:
    # katello-service start
Performing Online Database Backups

If you prefer, you can perform separate online backups of your databases. This is not necessary if you have performed complete offline backups.

Procedure 18.5. To Perform an Online Backup of the PostgreSQL Database:

  1. Determine the name of the Red Hat Satellite PostgreSQL database. The default name is foreman and is specified in the /usr/share/katello-installer/modules/foreman/manifests/database/postgresql.pp file. If you chose a different name for your database, it is stored as the value of db_database in the /etc/katello-installer/answers.katello-installer.yaml file.

    Note

    If you used the default database name, this variable has no value in the answers.katello-installer.yaml file.
    The Candlepin database name, candlepin, is not currently user configurable. It is specified in the /usr/share/katello-installer/modules/candlepin/manifests/init.pp file.
  2. Run the following commands to create online database backups. It is not necessary to stop PostgreSQL or Red Hat Satellite, and this process does not block logged-in users. However, the process can take several minutes to finish depending on database sizes.
    # runuser - postgres -c "pg_dump -Fc foreman > /backup/foreman.dump"
    # runuser - postgres -c "pg_dump -Fc candlepin > /backup/candlepin.dump"

Procedure 18.6. To Perform an Online Backup of the MongoDB Database:

  • Run the following command in the /backup directory to create the /backup/mongo_dump/pulp_database directory, including JSON files.
    # mongodump --host localhost --out $BDIR/mongo_dump
Verifying Your Backups

It is important to verify the results of your backups. The process creates the following archive files and directory:

# ls $BDIR
candlepin.dump
config_files.tar.gz
elastic_data.tar.gz
foreman.dump
mongo_dump/
pulp_data.tar
If you performed the optional offline backup of the databases, the following files also appear:
mongo_data.tar.gz
pgsql_data.tar.gz
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.