2.2. Backup and Restore Routines
To backup, verify, and restore a Satellite system, perform the tasks in this chapter.
2.2.1. Backing up the Embedded Database
To backup the Embedded RHN Satellite database, perform the following tasks:
Stop the Satellite Server:
rhn-satellite stop
Create the Backup using db-control
. Switch to the Oracle user before executing the db-control utility. Start the backup with the following command:
su - oracle
db-control backup [directory
]
Replace directory
with the absolute path to the location where you want to store your database backup. The process will take several minutes.
Resume the Satellite. Switch back to the root user and start up the Satellite:
exit
rhn-satellite start
Verify the Backup. The examine
option of db-control, issued as the Oracle user, conducts a quick check of the backup time stamp and determines any missing files:
su - oracle
db-control examine [directory
]
The verify
option of db-control, also issued as the Oracle user, conducts a thorough review. This includes checking the md5sum of each of the files in the backup:
db-control verify [directory
]
If the verification returns as successful, it is safe to rely on the contents of directory
to restore the database.
Note
As with embedded databases, it is recommended for external database users of Satellite to perform periodic backups as well. Consult your external database administrator for more information on supported backup procedures.
2.2.2. Backing up System Files
In addition to the database, also a number of system files and directories should be backed up. Below is the minimum list files and directories that should be backed up:
If possible, back up /var/satellite/
, as well. In case of failure, this will save lengthy download time. Since /var/satellite/
(specifically /var/satellite/redhat/NULL/
and /var/satellite/rhn/
) is primarily a duplicate of Red Hat's RPM repository, it can be regenerated with satellite-sync. Red Hat recommends the kickstart tree be backed up. In the case of disconnected satellites, /var/satellite/
must be backed up.
Backing up only these files and directories would require reinstalling the RHN Satellite Server ISO RPMs and re-registering the Satellite. In addition, Red Hat packages would need to be resynchronized using the satellite-sync tool. Finally, you would have to reinstall the /root/ssl-build/rhn-org-httpd-ssl-key-pair-MACHINE_NAME-VER-REL.noarch.rpm
. Another method would be to back up all of the files and directories mentioned above but reinstall the RHN Satellite without re-registering it. During the installation, cancel or skip the RHN registration and SSL certificate generation sections.
The final and most comprehensive method would be to back up the entire machine. This would save time in downloading and reinstalling but would require additional disk space and back up time.
Regardless of the backup method used, when you restore the Satellite from a backup, you must run the following command to schedule the recreation of search indexes the next time the rhn-search
service is started:
/etc/init.d/rhn-search cleanindex
2.2.3. Restoring the Embedded Database
RHN Database Control makes Embedded Database restoration a relatively simple process.
First, stop the database and related services with the following command:
rhn-satellite stop
Restore the Backup with db-control — Switch to the Oracle user and use the following command, replacing directory
with the directory that contains the backup:
su - oracle
db-control restore [directory
]
This not only restores the Embedded Database, but first verifies the contents of the backup directory using md5sums.
Resume the Satellite — Once the restoration is complete, return to root user mode and restart the database and related services:
exit
rhn-satellite start
Red Hat strongly recommends scheduling the backup process automatically using cron jobs. In the following example crontab excerpt and scripts, the database is backed up at 3 AM and the resulting files are moved to a separate repository at 6 AM. The following is an example excerpt from root crontab
file:
0 3 * * * backup-db.sh
0 6 * * * move-files.sh
The following is an example of the aforementioned backup-db.sh
script:
#!/bin/bash
{
/usr/sbin/rhn-satellite stop
su - oracle -c'
d=db-backup-$(date "+%F");
mkdir -p /tmp/$d;
db-control backup /tmp/$d
';
/usr/sbin/rhn-satellite start
} &> /dev/null
And, here is an example of move-files.sh
(replace [destination]
with the path to the backup directory:
#!/bin/bash
rsync -avz /tmp/db-backup-$(date "+%F") [destination]
&> /dev/null
Or:
#!/bin/bash
scp -r /tmp/db-backup-$(date "+%F") [destination]
&> /dev/null
In addition, a clean up script to remove older backup directories should be utilized to prevent the storage from filling up.