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.
The backup will be stored in backup.ldif text file.
#!/bin/sh slapcat -v -l backup.ldif
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