How to Export/Import Openldap (CentOS)
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.ldifImporting the LDAP Database
Before importing, ensure the LDAP server is stopped:
service ldap stopThen, import the database using slapadd:
slapadd -l backup.ldifAfter importing, restart the LDAP service:
service ldap startHandling 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!
