Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

so my server crashed and my backup is a couple of weeks old :(. so....

I have the old files that can be found in /var/lib/ldap

How can i recover my db, or export them in a ldif files.

Tnx all Zlatko

share|improve this question

migrated from Nov 24 '09 at 18:44

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

I'm assuming an openldap instance here, but the slapcat utility may prove useful. A few years ago I was running an ldap instance that was frequently blowing up its indices, so its fairly common to slapcat the database to a big ldif file, move out the db files, and then slapadd to regenerate the db from the ldif.

share|improve this answer

One of our machines running a third party system that used LDAP for authentication amongst other things has upset its LDAP setup before now (I've never worked out how as there are generally no graceless stops that I can account for).

The following has always worked to sort it:

  1. make sure the ldap daemon is stopped:
    /etc/init.d/ldap stop
  2. take a backup of the curent state just in case:
    cd /var/lib/ldap-dpp/
    rmdir -rfv /home/tmp_ldap/
    mkdir /home/tmp_ldap
    cp * /home/tmp_ldap/ -av
  3. run the recovery tool to rerun/clear out the transactions in the log:
    /usr/sbin/slapd_db_recover -v
  4. restart the ldap service:
    /etc/init.d/ldap start

(replacing any paths with correct ones for your system, of course)

If this fails, you have a backup from step 2 to roll back to ready to try something else. It might be worth taking a full system backup now before taking any steps to fix the issue, in case the attempts to fix things make something worse.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.