This recipe teaches you how to back up an OpenLDAP database by exporting the directory to an LDIF file, which can then be imported later to restore the database.
This recipe requires a CentOS system with a working network connection and administrative privileges either using the root
account or sudo
.
To back up an LDAP directory, export the directory using the slapcat
utility:
slapcat -b "dc=ldap,dc=example,dc=com" -l backup.ldif
To rebuild the directory from an export, follow these steps:
Stop the LDAP server:
service stop slapd.service
Import the file using
slapadd
:slapadd -f backup.ldif
Ensure the data files are owned by the
ldap
user:chown -R ldap.ldap /var/lib/ldap/*
Restart the LDAP server:
service restart slapd.service