Questo contenuto non è disponibile nella lingua selezionata.
Chapter 3. Backing up and restoring Red Hat Directory Server
Back up the Red Hat Directory Server database, configuration files, and custom schema files by using the the command line or the web console. You can also restore the database when the instance is offline or online.
3.1. Backing up Directory Server Copia collegamentoCollegamento copiato negli appunti!
A backup in Directory Server contains the following files:
-
An LDIF file
dse_index.ldif
containing database indexed attributes -
An LDIF file
dse_instance.ldif
containing instance configuration attributes -
A directory for each backend, for example
userRoot
, which contains.db
files for indexes defined in the database -
A transaction log file
log.*
-
A database version file
DBVERSION
Note that Directory Server does not support backing up individual databases.
For details about backing up other important files, such as the configuration, see Backing up configuration files, the certificate database, and custom schema files.
In contrast to a backup, you can export data as described in Exporting data from Directory Server. Use the export feature to export specific data from a server, such as a subtree, in LDIF format.
3.1.1. Backing up all databases using the command line while the instance is running Copia collegamentoCollegamento copiato negli appunti!
To back up all databases of the Directory Server instance that is running, use the dsconf backup create
command.
Directory Server cleans the changelog when the database is restored from the online backup. Therefore, using online backup requires you to reinitialize the replica after the database restore. To avoid reinitialization, use the offline backup.
Prerequisites
The
dirsrv
user has write permissions in the destination directory.Note that Directory Server uses its own private directories by default. As a result, backups and exports under directories
/var/tmp/
,/tmp/
, and/root/
fail unless you disabled the PrivateTmp systemd directive.- The Directory Server instance is running.
Procedure
Back up all databases:
dsconf <instance_name> backup create
# dsconf <instance_name> backup createdsconf <instance_name> backup createdsconf <instance_name> backup create The backup create task has finished successfully
Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default,
dsconf
stores the backup in a subdirectory called<instance_name>-YYYY_MM_DD_hh_mm_ss
in the/var/lib/dirsrv/slapd-<instance_name>/bak/
directory. To specify a different location, append a directory name to the command.-
Search the
/var/log/dirsrv/slapd-<instance_name>/errors
log for problems during the backup.
3.1.2. Backing up all databases using the command line while the instance is offline Copia collegamentoCollegamento copiato negli appunti!
To back up databases when the Directory Server instance is offline, use the dsctl db2bak
command.
Prerequisites
The
dirsrv
user has write permissions in the destination directory.Note that Directory Server uses its own private directories by default. As a result, backups and exports under directories
/var/tmp/
,/tmp/
, and/root/
fail unless you disabled the PrivateTmp systemd directive.- The Directory Server instance is not running.
Procedure
Back up all databases:
dsctl <instance_name> db2bak
# dsctl <instance_name> db2bak db2bak successful
Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default,
dsctl db2bak
stores the backup in the<instance_name>-YYYY_MM_DD_hh_mm_ss__
subdirectory in the/var/lib/dirsrv/slapd-<instance_name>/bak/
directory. To specify a different location, append a directory name to the command.Optionally, pass the
-v
option to the command to display verbose output:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Search the
/var/log/dirsrv/slapd-<instance_name>/errors
log for problems during the backup. Optional: Start the instance:
dsctl <instance_name> start
# dsctl <instance_name> start
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.1.3. Backing up all databases using the web console Copia collegamentoCollegamento copiato negli appunti!
Directory Server supports data backup using the web console.
Directory Server cleans the changelog when the database is restored from the online backup. Therefore, using online backup requires you to reinitialize the replica after the database restore. To avoid reinitialization, use the offline backup.
Prerequisites
The
dirsrv
user has write permissions in the destination directory.Note that Directory Server uses its own private directories by default. As a result, backups and exports under
/var/tmp/
,/tmp/
, and/root/
directories fail unless you disabled the PrivateTmp systemd directive.- You are logged in to the instance in the web console.
Procedure
- Click the Manage Backups. button, and select
- Click .
- Enter a name for the backup, such as a time stamp to indicate the creation date and time of the backup.
- Click .
-
To check the log for problems during the backup, open the
menu.
The server stores the backup in a subdirectory with the name you entered in the /var/lib/dirsrv/slapd-<instance_name>/bak/
directory.
3.1.4. Backing up configuration files, the certificate database, and custom schema files Copia collegamentoCollegamento copiato negli appunti!
When you back up databases while the instance is online or offline, Directory Server also backs up configuration files, the certificate database, and custom schema files. The dsconf backup create
and dsctl db2bak
commands back up files to the /var/lib/dirsrv/slapd-<instance_name>/bak/<example_backup>/config_files/
backup default directory. You might need these files to restore the instance on a different server after a hardware failure.
During the backup, do not update the certificate database. Otherwise, this database might not be consistent in the backup.
Procedure
- Perform backup of Directory Server while the instance is running or is offline as described in Backing up all databases using the command line while the instance is running or Backing up all databases using the command line while the instance is offline.
Verification
Find backed up configuration files in the backup directory:
ls /var/lib/dirsrv/slapd-<instance_name>/bak/<example_backup>/config_files/
# ls /var/lib/dirsrv/slapd-<instance_name>/bak/<example_backup>/config_files/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteDirectory Server does not automatically restore backed up configuration files. You need to restore these files manually.
3.2. Restoring Directory Server Copia collegamentoCollegamento copiato negli appunti!
In certain situations, for example after a hardware failure, you need to restore Directory Server. You can do that using the command line or the web console. Note that Directory Server does not support restoration of individual databases.
When you want to populate the database with custom data, use the import feature. You can import specific data from a server in LDIF format. For details, see Importing data to Directory Server.
3.2.1. Restoring all databases using the command line while the instance is running Copia collegamentoCollegamento copiato negli appunti!
To restore all databases on the Directory Server instance that is running, use the dsconf backup restore
command.
Prerequisites
- You have a Directory Server backup.
-
The
dirsrv
user has read permissions in the backup directory. - The Directory Server instance is running.
Procedure
Restore all databases from the backup stored in the
/var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ss
directory:dsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ss
# dsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ssdsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ssdsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ssdsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ssdsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ssdsconf <instance_name> backup restore /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ss The backup restore task has finished successfully
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Search the
/var/log/dirsrv/slapd-<instance_name>/errors
log for problems during the restore.
3.2.2. Restoring all databases using the command line while the instance is offline Copia collegamentoCollegamento copiato negli appunti!
To restore all databases when the instance is offline, use the dsctl bak2db
command.
Prerequisites
- You have a Directory Server backup.
-
The
dirsrv
user has read permissions in the backup directory. - The Directory Server instance is not running.
Procedure
Restore all databases from the backup stored in the
/var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ss
directory:dsctl <instance_name> bak2db /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ss/
# dsctl <instance_name> bak2db /var/lib/dirsrv/slapd-<instance_name>/bak/<instance_name>-YYYY_MM_DD_hh_mm_ss/ bak2db successful
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optionally, pass the
-v
option to the command to display verbose output:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Search the
/var/log/dirsrv/slapd-<instance_name>/errors
log for problems during the restore. Optional: Start the instance:
*dsctl <instance_name> start`
# *dsctl <instance_name> start`
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2.3. Restoring all databases using the web console Copia collegamentoCollegamento copiato negli appunti!
Directory Server supports restoring data using the web console.
Prerequisites
-
A backup is stored in the
/var/lib/dirsrv/slapd-<instance_name>/bak/
directory. -
The
dirsrv
user has read permissions in the backup directory. - You are logged in to the instance in the web console.
Procedure
-
Click the
Actions
menu, and selectManage Backups
. The displayed window lists the available backups in the/var/lib/dirsrv/slapd-<instance_name>/bak/
directory. -
Open the
Actions
menu next to the backup you want to restore, and selectRestore Backup
. - Click to confirm.
-
To check the log for problems during the restore, open the
menu.
3.2.4. Restoring databases that include replicated entries Copia collegamentoCollegamento copiato negli appunti!
Several situations can occur when a supplier server is restored:
The consumer servers are also restored.
For the very unlikely situation, that all databases are restored from backups taken at exactly the same time (so that the data are in sync), the consumers remain synchronized with the supplier, and it is not necessary to do anything else. Replication resumes without interruption.
Only the supplier is restored.
If only the supplier is restored or if the consumers are restored from backups taken at different times, reinitialize the consumers for the supplier to update the data in the database.
Changelog entries have not yet expired on the supplier server.
If the supplier’s changelog has not expired since the database backup was taken, then restore the local consumer and continue with normal operations. This situation occurs only if the backup was taken within a period of time that is shorter than the value set for the maximum changelog age attribute,
nsslapd-changelogmaxage
, in thecn=changelog,cn=<database_name>,cn=ldbm database,cn=plugins,cn=config
entry.Directory Server automatically detects the compatibility between the replica and its changelog. If a mismatch is detected, the server removes the old changelog file and creates a new, empty one.
Changelog entries have expired on the supplier server since the time of the local backup.
If changelog entries have expired, reinitialize the consumer.
Example 3.1. Restoring a Directory Server replication topology
To restore all servers in a replication environment, consisting of two suppliers and two consumer servers:
- Reinitialize the first supplier using either restore or import.
Online-initialize the remaining servers by using replication:
- Initialize the second supplier from the first one.
- Initialize the consumers from the supplier.
- On each server, display the replication status to verify that replication works correctly.
The changelog associated with the restored database will be erased during the restore operation. A message will be logged to the supplier server’s log files indicating that reinitialization is required.
3.2.5. Restoring configuration files, the certificate database, and custom schema files Copia collegamentoCollegamento copiato negli appunti!
You can manually restore configuration files, the certificate database, and custom schema files from the backup.
Prerequisites
- You have a Directory Server backup.
-
The
dirsrv
user has read permissions in the/var/lib/dirsrv/slapd-<instance_name>/bak/
backup directory. - The Directory Server instance is not running.
Procedure
Copy files you want to restore from the the backup directory to the Directory Server configuration directory. For example, to restore the
dse.ldif
configuration file, enter:cp /var/lib/dirsrv/slapd-<instance_name>/bak/<example_backup>/config_files/dse.ldif /etc/dirsrv/slapd-<instance_name>/
# cp /var/lib/dirsrv/slapd-<instance_name>/bak/<example_backup>/config_files/dse.ldif /etc/dirsrv/slapd-<instance_name>/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the instance:
dsctl <instance_name> start
# dsctl <instance_name> start
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the server restored the server configuration:
dsconf <instance_name> config get
# dsconf <instance_name> config get
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3. Enabling members of a group to back up Directory Server and performing the backup as one of the group members Copia collegamentoCollegamento copiato negli appunti!
You can configure that members of a group have permissions to back up an instance and perform the backup. This increases the security because you no longer need to set the credentials of cn=Directory Manager
in your backup script or cron jobs. Additionally, you can easily grant and revoke the backup permissions by modifying the group.
3.3.1. Enabling a group to back up Directory Server Copia collegamentoCollegamento copiato negli appunti!
Use this procedure to add the cn=backup_users,ou=groups,dc=example,dc=com
group and enable members of this group to create backup tasks.
Prerequisites
-
The entry
ou=groups,dc=example,dc=com
exists in the database.
Procedure
Create the
cn=backup_users,ou=groups,dc=example,dc=com
group:dsidm <instance_name> -b "dc=example,dc=com" group create --cn backup_users
# dsidm <instance_name> -b "dc=example,dc=com" group create --cn backup_users
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add an access control instruction (ACI) that allows members of the
cn=backup_users,ou=groups,dc=example,dc=com
group to create backup tasks:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a user:
Create a user account:
dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"
# dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"dsidm <instance_name> -b "dc=example,dc=com" user create --uid="example" --cn="example" --uidNumber="1000" --gidNumber="1000" --homeDirectory="/home/example/" --displayName="Example User"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set a password on the user account:
dsidm <instance_name> -b "dc=example,dc=com" account reset_password "uid=example,ou=People,dc=example,dc=com" "password"
# dsidm <instance_name> -b "dc=example,dc=com" account reset_password "uid=example,ou=People,dc=example,dc=com" "password"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the
uid=example,ou=People,dc=example,dc=com
user to thecn=backup_users,ou=groups,dc=example,dc=com
group:dsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=com
# dsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=comdsidm <instance_name> -b "dc=example,dc=com" group add_member backup_users uid=example,ou=People,dc=example,dc=com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display the ACIs set on the
cn=config
entry:ldapsearch -o ldif-wrap=no -LLLx -D "cn=Directory Manager" -W -H ldap://server.example.com -b cn=config aci=* aci -s base
# ldapsearch -o ldif-wrap=no -LLLx -D "cn=Directory Manager" -W -H ldap://server.example.com -b cn=config aci=* aci -s base dn: cn=config aci: (target = "ldap:///cn=backup,cn=tasks,cn=config")(targetattr="*")(version 3.0 ; acl "permission: Allow backup_users group to create backup tasks" ; allow (add, read, search) groupdn = "ldap:///cn=backup_users,ou=groups,dc=example,dc=com";) aci: (target = "ldap:///cn=config")(targetattr = "nsslapd-bakdir || objectClass")(version 3.0 ; acl "permission: Allow backup_users group to access bakdir attribute" ; allow (read,search) groupdn = "ldap:///cn=backup_users,ou=groups,dc=example,dc=com";) ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3.2. Performing a backup as a regular user Copia collegamentoCollegamento copiato negli appunti!
You can perform backups as a regular user instead of cn=Directory Manager
.
Prerequisites
-
You enabled members of the
cn=backup_users,ou=groups,dc=example,dc=com
group to perform backups. -
The user you use to perform the backup is a member of the
cn=backup_users,ou=groups,dc=example,dc=com
group.
Procedure
Create a backup task using one of the following methods:
Using the
dsconf backup create
command:dsconf -D "uid=example,ou=People,dc=example,dc=com" ldap://server.example.com backup create
# dsconf -D "uid=example,ou=People,dc=example,dc=com" ldap://server.example.com backup create
Copy to Clipboard Copied! Toggle word wrap Toggle overflow By manually creating the task:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the backup was created:
ls -l /var/lib/dirsrv/slapd-instance_name/bak/
# ls -l /var/lib/dirsrv/slapd-instance_name/bak/ total 0 drwx------. 3 dirsrv dirsrv 108 Jul 23 12:55 backup-2021_07_23_12_55_00 ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow