Wednesday, 2 March 2016

Backup and Restore OpenLDAP Database



Backup and Restore OpenLDAP Database
=====================================

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.


# cd /var/lib/ldap

slapcat -v -l ldap.diff



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



Note:  first take /var/lib/ldap  backup

Ref: http://mindref.blogspot.in/2011/06/ldap-database-backup-restore.html

No comments: