How to backup and restore your LDAP database
How to backup and restore your LDAP database
OpenLDAP is open source implementation of the LDAP.
Once LDAP server is set and running you need to take care about backups.
If your LDAP backend is one of bdb, hdb or null you can use slapcat. To check it see /etc/ldap/slapd.conf.
Here is an example:
debian:~# /usr/sbin/slapcat -v -l /home/backup/ldap.diff
1 |
#!/bin/sh |
2 |
LDAPBK=ldap-$( date +%y%m%d-%H%M ).ldif |
3 |
BACKUPDIR=/home/backups |
4 |
<pre>/usr/sbin/slapcat - v -b "dc=yourDC,dc=local" -l $BACKUPDIR/$LDAPBK |
5 |
gzip -9 $BACKUPDIR/$LDAPBK |
debian:~# /etc/init.d/slapd stop
2. delete old database (make sure you are in right directory to use rm):
debian:~# cd /var/lib/ldap
rm -rf *
2. Restore database from LDIF file:
debian:~# /usr/sbin/slapadd -l backup.ldif
debian:~# /etc/init.d/slapd start