Chapter 18. Backup and Disaster Recovery
18.1. Backing up Red Hat Satellite
/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
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:
- Prepare your backup location:
# umask 0027 # export BDIR=/backup # mkdir $BDIR # chgrp postgres $BDIR # chmod 770 $BDIR # cd $BDIR
- 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
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.
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 thersync
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 thekatello-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.
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
Procedure 18.4. To Perform a Complete Offline Database Backup:
- Ensure the Satellite Server is completely stopped:
# katello-service stop
- 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/
- Restart the required services:
# katello-service start
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:
- 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 ofdb_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 theanswers.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. - 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
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
mongo_data.tar.gz pgsql_data.tar.gz