Chapter 1. Backing up Directory Server

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.

1.1. Backing up all databases using the command line while the instance is running

To back up all databases of the Directory Server instance that is running, use the dsconf backup create command.

Important

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

  1. Back up all databases:

    # dsconf -D "cn=Directory Manager" ldap://server.example.com backup create
    The backup create task has finished successfully

    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.

  2. Search the /var/log/dirsrv/slapd-instance_name/errors log for problems during the backup.

Additional resources

1.2. Backing up all databases using the command line while the instance is offline

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

  1. Back up all databases:

    # dsctl instance_name db2bak
    db2bak successful

    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:

    # dsctl -v instance_name db2bak
    ...
    DEBUG: Instance allocated
    DEBUG: systemd status -> True
    ...
    INFO: db2bak successful
  2. Search the /var/log/dirsrv/slapd-instance_name/errors log for problems during the backup.
  3. Optional: Start the instance:

    # dsctl instance_name start

1.3. Backing up all databases using the web console

Directory Server supports data backup using the web console.

Important

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

  1. Click the Actions button, and select Manage Backups.
  2. Click Create Backup.
  3. Enter a name for the backup, such as a time stamp to indicate the creation date and time of the backup.
  4. Click Create Backup.
  5. To check the log for problems during the backup, open the MonitoringLoggingErrors Log menu.

The server stores the backup in a subdirectory with the name you entered in the /var/lib/dirsrv/slapd-instance_name/bak/ directory.

1.4. Backing up configuration files, the certificate database, and custom schema files

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.

Important

During the backup, do not update the certificate database. Otherwise, this database might not be consistent in the backup.

Procedure

Verification

  • Find backed up configuration files in the backup directory:

    # ls /var/lib/dirsrv/slapd-instance_name/bak/example_backup/config_files/
    Note

    Directory Server does not automatically restore backed up configuration files. You need to restore these files manually.