Moorfleeter Deich 216, 22113 Hamburg
+49 1774661716info@bastcom.deMon–Fri: 09:00–18:00

Blog

ITWeb Knowledge

Tech news, AI and practical knowledge – around WordPress, Joomla, hosting and web development.

How to Export/Import Openldap (CentOS)

← Back to the blog

Introduction to LDAP database management

LDAP (Lightweight Directory Access Protocol) is a common protocol for managing user information and authentication data. Backup and recovery of an LDAP database is crucial to avoid data loss and ensure smooth system management. This guide describes how to export, import and handle your LDAP database.

Exporting the LDAP Database

Use slapcat to export your LDAP database to LDIF file:

slapcat > backup.ldif

Importing the LDAP Database

Before importing, ensure the LDAP server is stopped:

service ldap stop

Then, import the database using slapadd:

slapadd -l backup.ldif

After importing, restart the LDAP service:

service ldap start

Handling Duplicate Data Errors

If you encounter an error stating that the same data already exists in the database, you may need to remove the old database before importing.

To do this on CentOS, navigate to the LDAP data directory and delete its contents:

cd /var/lib/ldap/
rm -rf *

Only delete the contents of /var/lib/ldap/Not other system files!