Chapter 9. Backing Up and Restoring Identity Management Red Hat Enterprise Linux Identity Management provides a solution to manually back up and restore the IdM system, for example when a server stops performing correctly or data loss occurs. During backup, the system creates a directory containing information on your IdM setup and stores it. During restore, you can use this backup directory to bring your original IdM setup back. Important Use the backup and restore procedures described in this chapter only if you cannot rebuild the lost part of the IdM server group from the remaining servers in the deployment, by reinstalling the lost replicas as replicas of the remaining ones. The "Backup and Restore in IdM/IPA" Knowledgebase solution describes how to avoid losses by maintaining several server replicas. Rebuilding from an existing replica with the same data is preferable, because the backed-up version usually contains older, thus potentially outdated, information. The potential threat scenarios that backup and restore can prevent include: Catastrophic hardware failure on a machine occurs and the machine becomes incapable of further functioning. In this situation: Reinstall the operating system from scratch. Configure the machine with the same host name, fully qualified domain name (FQDN), and IP address. Install the IdM packages as well as all other optional packages relating to IdM that were present on the original system. Restore the full backup of the IdM server. An upgrade on an isolated machine fails. The operating system remains functional, but the IdM data is corrupted, which is why you want to restore the IdM system to a known good state. Important In cases of hardware or upgrade failure, such as the two mentioned above, restore from backup only if all replicas or a replica with a special role, such as the only certificate authority (CA), were lost. If a replica with the same data still exists, it is recommended to delete the lost replica and then rebuild it from the remaining one. Undesirable changes were made to the LDAP content, for example entries were deleted, and you want to revert them. Restoring backed-up LDAP data returns the LDAP entries to the state without affecting the IdM system itself. The restored server becomes the only source of information for IdM; other master servers are re-initialized from the restored server. Any data created after the last backup was made are lost. Therefore you should not use the backup and restore solution for normal system maintenance. If possible, always rebuild the lost server by reinstalling it as a replica. The backup and restore features can be managed only from the command line and are not available in the IdM web UI. 9.1. Full-Server Backup and Data-Only Backup IdM offers two backup options: Full-IdM server backup Full-server backup creates a backup copy of all the IdM server files as well as LDAP data, which makes it a standalone backup. IdM affects hundreds of files; the files that the backup process copies is a mix of whole directories and specific files, such as configuration files or log files, and relate directly to IdM or to various services that IdM depends on. Because the full-server backup is a raw file backup, it is performed offline. The script that performs the full-server backup stops all IdM services to ensure a safe course of the backup process. For the full list of files and directories that the full-server backup copies, see Section 9.1.3, "List of Directories and Files Copied During Backup" . Data-only Backup The data-only backup only creates a backup copy of LDAP data and the changelog. The process backs up the IPA-REALM instance and can also back up multiple back ends or only a single back end; the back ends include the IPA back end and the CA Dogtag back end. This type of backup also backs up a record of the LDAP content stored in LDIF (LDAP Data Interchange Format). The data-only backup can be performed both online and offline. By default, IdM stores the created backups in the /var/lib/ipa/backup/ directory. The naming conventions for the subdirectories containing the backups are: ipa-full-YEAR-MM-DD-HH-MM-SS in the GMT time zone for the full-server backup ipa-data-YEAR-MM-DD-HH-MM-SS in the GMT time zone for the data-only backup 9.1.1. Creating a Backup Both full-server and data-only backups are created using the ipa-backup utility which must always be run as root. To create a full-server backup, run ipa-backup . Important Performing a full-server backup stops all IdM services because the process must run offline. The IdM services will start again after the backup is finished. To create a data-only backup, run the ipa-backup --data command. You can add several additional options to ipa-backup : --online performs an online backup; this option is only available with data-only backups --logs includes the IdM service log files in the backup For further information on using ipa-backup , see the ipa-backup (1) man page. 9.1.1.1. Working Around Insufficient Space on Volumes Involved During Backup This section describes how to address problems if directories involved in the IdM backup process are stored on volumes with insufficient free space. Insufficient Space on the Volume That Contains /var/lib/ipa/backup/ If the /var/lib/ipa/backup/ directory is stored on a volume with insufficient free space, it is not possible to create a backup. To address the problem, use one of the following workarounds: Create a directory on a different volume and link it to /var/lib/ipa/backup/ . For example, if /home is stored on a different volume with enough free space: Create a directory, such as /home/idm/backup/ : Set the following permissions to the directory: If /var/lib/ipa/backup/ contains existing backups, move them to the new directory: Remove the /var/lib/ipa/backup/ directory: Create the /var/lib/ipa/backup/ link to the /home/idm/backup/ directory: Mount a directory stored on a different volume to /var/lib/ipa/backup/ . For example, if /home is stored on a different volume with enough free space, create /home/idm/backup/ and mount it to /var/lib/ipa/backup/ : Create the /home/idm/backup/ directory: Set the following permissions to the directory: If /var/lib/ipa/backup/ contains existing backups, move them to the new directory: Mount /home/idm/backup/ to /var/lib/ipa/backup/ : To automatically mount /home/idm/backup/ to /var/lib/ipa/backup/ when the system boots, append the following to the /etc/fstab file: Insufficient Space on the Volume That Contains /tmp If the backup fails due to insufficient space being available in the /tmp directory, change the location of the staged files to be created during the backup by using the TMPDIR environment variable: For more details, see the ipa-backup command fails to finish Knowledgebase solution. 9.1.2. Encrypting Backup You can encrypt the IdM backup using the GNU Privacy Guard (GPG) encryption. To create a GPG key: Create a keygen file containing the key details, for example, by running cat >keygen <<EOF and providing the required encryption details to the file from the command line: Generate a new key pair called backup and feed the contents of keygen to the command. The following example generates a key pair with the path names /root/backup.sec and /root/backup.pub : To create a GPG-encrypted backup, pass the generated backup key to ipa-backup by supplying the following options: --gpg , which instructs ipa-backup to perform the encrypted backup --gpg-keyring=GPG_KEYRING , which provides the full path to the GPG keyring without the file extension. For example: Note You might experience problems if your system uses the gpg2 utility to generate GPG keys because gpg2 requires an external program to function. To generate the key purely from console in this situation, add the pinentry-program /usr/bin/pinentry-curses line to the .gnupg/gpg-agent.conf file before generating a key. 9.1.3. List of Directories and Files Copied During Backup Directories: Files: Log files and directories:

Commands:
mkdir -p /home/idm/backup/
chown root:root /home/idm/backup/ chmod 700 /home/idm/backup/
mv /var/lib/ipa/backup/* /home/idm/backup/
rm -rf /var/lib/ipa/backup/
ln -s /home/idm/backup/ /var/lib/ipa/backup/
mkdir -p /home/idm/backup/
chown root:root /home/idm/backup/ chmod 700 /home/idm/backup/
mv /var/lib/ipa/backup/* /home/idm/backup/
mount -o bind /home/idm/backup/ /var/lib/ipa/backup/
/home/idm/backup/ /var/lib/ipa/backup/ none bind 0 0
TMPDIR= /path/to/backup ipa-backup
cat >keygen <<EOF > %echo Generating a standard key > Key-Type: RSA > Key-Length:2048 > Name-Real: IPA Backup > Name-Comment: IPA Backup > Name-Email: root@example.com > Expire-Date: 0 > %pubring /root/backup.pub > %secring /root/backup.sec > %commit > %echo done > EOF
gpg --batch --gen-key keygen gpg --no-default-keyring --secret-keyring /root/backup.sec --keyring /root/backup.pub --list-secret-keys
ipa-backup --gpg --gpg-keyring=/root/backup
/usr/share/ipa/html /root/.pki /etc/pki-ca /etc/pki/pki-tomcat /etc/sysconfig/pki /etc/httpd/alias /var/lib/pki /var/lib/pki-ca /var/lib/ipa/sysrestore /var/lib/ipa-client/sysrestore /var/lib/ipa/dnssec /var/lib/sss/pubconf/krb5.include.d/ /var/lib/authconfig/last /var/lib/certmonger /var/lib/ipa /var/run/dirsrv /var/lock/dirsrv
/etc/named.conf /etc/named.keytab /etc/resolv.conf /etc/sysconfig/pki-ca /etc/sysconfig/pki-tomcat /etc/sysconfig/dirsrv /etc/sysconfig/ntpd /etc/sysconfig/krb5kdc /etc/sysconfig/pki/ca/pki-ca /etc/sysconfig/ipa-dnskeysyncd /etc/sysconfig/ipa-ods-exporter /etc/sysconfig/named /etc/sysconfig/ods /etc/sysconfig/authconfig /etc/ipa/nssdb/pwdfile.txt /etc/pki/ca-trust/source/ipa.p11-kit /etc/pki/ca-trust/source/anchors/ipa-ca.crt /etc/nsswitch.conf /etc/krb5.keytab /etc/sssd/sssd.conf /etc/openldap/ldap.conf /etc/security/limits.conf /etc/httpd/conf/password.conf /etc/httpd/conf/ipa.keytab /etc/httpd/conf.d/ipa-pki-proxy.conf /etc/httpd/conf.d/ipa-rewrite.conf /etc/httpd/conf.d/nss.conf /etc/httpd/conf.d/ipa.conf /etc/ssh/sshd_config /etc/ssh/ssh_config /etc/krb5.conf /etc/ipa/ca.crt /etc/ipa/default.conf /etc/dirsrv/ds.keytab /etc/ntp.conf /etc/samba/smb.conf /etc/samba/samba.keytab /root/ca-agent.p12 /root/cacert.p12 /var/kerberos/krb5kdc/kdc.conf /etc/systemd/system/multi-user.target.wants/ipa.service /etc/systemd/system/multi-user.target.wants/sssd.service /etc/systemd/system/multi-user.target.wants/certmonger.service /etc/systemd/system/pki-tomcatd.target.wants/pki-tomcatd@pki-tomcat.service /var/run/ipa/services.list /etc/opendnssec/conf.xml /etc/opendnssec/kasp.xml /etc/ipa/dnssec/softhsm2.conf /etc/ipa/dnssec/softhsm_pin_so /etc/ipa/dnssec/ipa-ods-exporter.keytab /etc/ipa/dnssec/ipa-dnskeysyncd.keytab /etc/idm/nssdb/cert8.db /etc/idm/nssdb/key3.db /etc/idm/nssdb/secmod.db /etc/ipa/nssdb/cert8.db /etc/ipa/nssdb/key3.db /etc/ipa/nssdb/secmod.db
/var/log/pki-ca /var/log/pki/ /var/log/dirsrv/slapd-PKI-IPA /var/log/httpd /var/log/ipaserver-install.log /var/log/kadmind.log /var/log/pki-ca-install.log /var/log/messages /var/log/ipaclient-install.log /var/log/secure /var/log/ipaserver-uninstall.log /var/log/pki-ca-uninstall.log /var/log/ipaclient-uninstall.log /var/named/data/named.run