Chapter 5. Recovering from data loss with IdM backups
You can use the ipa-restore utility to restore an IdM server to a previous state captured in an IdM backup.
5.1. When to restore from an IdM backup Copy linkLink copied to clipboard!
You can respond to several disaster scenarios by restoring from an IdM backup:
- Undesirable changes were made to the LDAP content: Entries were modified or deleted, replication carried out those changes throughout the deployment, and you want to revert those changes. Restoring a data-only backup returns the LDAP entries to the previous state without affecting the IdM configuration itself.
- Total Infrastructure Loss, or loss of all CA instances: If a disaster damages all Certificate Authority replicas, the deployment has lost the ability to rebuild itself by deploying additional servers. In this situation, restore a backup of a CA Replica and build new replicas from it.
An upgrade on an isolated server failed: 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. Red Hat recommends working with Technical Support to diagnose and troubleshoot the issue. If those efforts fail, restore from a full-server backup.
ImportantThe preferred solution for hardware or upgrade failure is to rebuild the lost server from a replica. For more information, see Recovering a single server with replication.
5.2. Considerations when restoring from an IdM backup Copy linkLink copied to clipboard!
If you have a backup created with the ipa-backup utility, you can restore your IdM server or the LDAP content to the state they were in when the backup was performed.
The following are the key considerations while restoring from an IdM backup:
You can only restore a backup on a server that matches the configuration of the server where the backup was originally created. The server must have:
- The same hostname
- The same IP address
- The same version of IdM software
- If one IdM server among many is restored, the restored server becomes the only source of information for IdM. All other servers must be re-initialized from the restored server.
- Since any data created after the last backup will be lost, do not use the backup and restore solution for normal system maintenance.
- If a server is lost, Red Hat recommends rebuilding the server by reinstalling it as a replica, instead of restoring from a backup. Creating a new replica preserves data from the current working environment. For more information, see Preparing for server loss with replication.
- The backup and restore features can only be managed from the command line and are not available in the IdM web UI.
-
You cannot restore from backup files located in the
/tmpor/var/tmpdirectories. The IdM Directory Server uses a PrivateTmp directory and cannot access the/tmpor/var/tmpdirectories commonly available to the operating system.
Restoring from a backup requires the same software (RPM) versions on the target host as were installed when the backup was performed. Due to this, Red Hat recommends restoring from a Virtual Machine snapshot rather than a backup. For more information, see Recovering from data loss with VM snapshots.
5.3. Restoring an IdM server from a backup Copy linkLink copied to clipboard!
Restore an IdM server, or its LDAP data, from an IdM backup.
Figure 5.1. Replication topology used in this example
| Server host name | Function |
|---|---|
|
| The server that needs to be restored from backup. |
|
|
A Certificate Authority (CA) replica connected to the |
|
|
A replica connected to the |
Prerequisites
-
You have generated a full-server or data-only backup of the IdM server with the
ipa-backuputility. See Creating a backup. -
Your backup files are not in the
/tmpor/var/tmpdirectories. - Before performing a full-server restore from a full-server backup, uninstall IdM from the server and reinstall IdM using the same server configuration as before.
Procedure
Use the
ipa-restoreutility to restore a full-server or data-only backup.If the backup directory is in the default
/var/lib/ipa/backup/location, enter only the name of the directory:ipa-restore ipa-full-2020-01-14-12-02-32
[root@server1 ~]# ipa-restore ipa-full-2020-01-14-12-02-32Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the backup directory is not in the default location, enter its full path:
ipa-restore /mybackups/ipa-data-2020-02-01-05-30-00
[root@server1 ~]# ipa-restore /mybackups/ipa-data-2020-02-01-05-30-00Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
ipa-restoreutility automatically detects the type of backup that the directory contains, and performs the same type of restore by default. To perform a data-only restore from a full-server backup, add the--dataoption to theipa-restorecommand:ipa-restore --data ipa-full-2020-01-14-12-02-32
[root@server1 ~]# ipa-restore --data ipa-full-2020-01-14-12-02-32Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Enter the Directory Manager password.
Directory Manager (existing master) password:
Directory Manager (existing master) password:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter
yesto confirm overwriting current data with the backup.Preparing restore from /var/lib/ipa/backup/ipa-full-2020-01-14-12-02-32 on server1.example.com Performing FULL restore from FULL backup Temporary setting umask to 022 Restoring data will overwrite existing live data. Continue to restore? [no]: yes
Preparing restore from /var/lib/ipa/backup/ipa-full-2020-01-14-12-02-32 on server1.example.com Performing FULL restore from FULL backup Temporary setting umask to 022 Restoring data will overwrite existing live data. Continue to restore? [no]: yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
ipa-restoreutility disables replication on all servers that are available:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The utility then stops IdM services, restores the backup, and restarts the services:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Re-initialize all replicas connected to the restored server:
List all replication topology segments for the
domainsuffix, taking note of topology segments involving the restored server.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Re-initialize the
domainsuffix for all topology segments with the restored server.In this example, perform a re-initialization of
caReplica2with data fromserver1.ipa-replica-manage re-initialize --from=server1.example.com
[root@caReplica2 ~]# ipa-replica-manage re-initialize --from=server1.example.com Update in progress, 2 seconds elapsed Update succeededCopy to Clipboard Copied! Toggle word wrap Toggle overflow Moving on to Certificate Authority data, list all replication topology segments for the
casuffix.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Re-initialize all CA replicas connected to the restored server.
In this example, perform a
csreplicare-initialization ofcaReplica2with data fromserver1.ipa-csreplica-manage re-initialize --from=server1.example.com
[root@caReplica2 ~]# ipa-csreplica-manage re-initialize --from=server1.example.com Directory Manager password: Update in progress, 3 seconds elapsed Update succeededCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Continue moving outward through the replication topology, re-initializing successive replicas, until all servers have been updated with the data from restored server
server1.example.com.In this example, we only have to re-initialize the
domainsuffix onreplica3with the data fromcaReplica2:ipa-replica-manage re-initialize --from=caReplica2.example.com
[root@replica3 ~]# ipa-replica-manage re-initialize --from=caReplica2.example.com Directory Manager password: Update in progress, 3 seconds elapsed Update succeededCopy to Clipboard Copied! Toggle word wrap Toggle overflow Clear SSSD’s cache on every server to avoid authentication problems due to invalid data:
Stop the SSSD service:
systemctl stop sssd
[root@server ~]# systemctl stop sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove all cached content from SSSD:
sss_cache -E
[root@server ~]# sss_cache -ECopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the SSSD service:
systemctl start sssd
[root@server ~]# systemctl start sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Reboot the server.
5.4. Restoring from an encrypted backup Copy linkLink copied to clipboard!
This procedure restores an IdM server from an encrypted IdM backup. The ipa-restore utility automatically detects if an IdM backup is encrypted and restores it using the GPG2 root keyring.
Prerequisites
- A GPG-encrypted IdM backup. See Creating encrypted IdM backups.
- The LDAP Directory Manager password
- The passphrase used when creating the GPG key
Procedure
If you used a custom keyring location when creating the GPG2 keys, verify that the
$GNUPGHOMEenvironment variable is set to that directory. See Creating a GPG2 key.echo $GNUPGHOME
[root@server ~]# echo $GNUPGHOME /root/backupCopy to Clipboard Copied! Toggle word wrap Toggle overflow Provide the
ipa-restoreutility with the backup directory location.ipa-restore ipa-full-2020-01-13-18-30-54
[root@server ~]# ipa-restore ipa-full-2020-01-13-18-30-54Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the Directory Manager password.
Directory Manager (existing master) password:
Directory Manager (existing master) password:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the passphrase you used when creating the GPG key.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Re-initialize all replicas connected to the restored server. See Restoring an IdM server from backup.