How to Backup and Restore OpenLDAP Database
- Details
- Veröffentlicht: 04. September 2013
- Zugriffe: 11124
5.0 out of
5
based on
216 votes
Instead of backup / restore of actual ldap database (hdb, etc) we will export/import ldap directory tree into ldif format that ultimately let us do the same, however without any particular database implementation specifics.
Backup
The backup will be stored in backup.ldif text file.
#!/bin/sh slapcat -v -l backup.ldif
Restore
The restore will go through replacing current database from a one we have in ldif backup.
#!/bin/sh # Stop slapd daemon /etc/init.d/slapd stop # Remove current database rm -rf /var/lib/ldap/* # Import directory tree from backup slapadd -l backup.ldif # Fix permissions chown -R openldap:openldap /var/lib/ldap/* # Start slapd daemon /etc/init.d/slapd start