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

I am trying to restore my OpenLDAP server from an ldif file I made before it went horribly wrong.

All of the websites I found talk about using slapadd but when I run slapadd -v -l ~ns01/openldap_config.ldif it returns the error Could not stat config file "/etc/ldap/slapd.conf" : No such file or directory (2) slapadd: bad configuration file!

When I look in the directory indeed the file does not exist, but this is because Ubuntu 11.10 is running in RTC mode, my LDAP server uses the /etc/slapd.d/cn=config for the configuration. So? What am I missing? Is slapadd the wrong tool to use?

As I said above I running on Ubuntu 11.10 server edition 64-bit.

share|improve this question
up vote 3 down vote accepted

Looking through the documentation it looks as if you may be able to use the -F flag to slapadd to specify a configuration directory, rather than a configuration file:

   -F confdir
          specify a config directory.  If both -f and  -F  are  specified,
          the  config  file will be read and converted to config directory
          format and written  to  the  specified  directory.   If  neither
          option  is  specified,  an  attempt  to  read the default config
          directory will be made before trying to use the  default  config
          file. If a valid config directory exists then the default config
          file is ignored. If dry-run mode is also specified,  no  conver‐
          sion will occur.

If this doesn't work (e.g., you're missing the contents of your cn=config tree), possibly this thread has some suggestions.

share|improve this answer
Thanks for the help, this is the best lead I have had so far. – ianc1215 Oct 20 '11 at 6:16
Well I reinstalled slapd after I got my server back online. I could just use the default config as base correct? – ianc1215 Oct 20 '11 at 6:23
That sounds reasonable. I've (intentionally) avoided the cn=config stuff so far, so I'm mostly offering conjecture. – larsks Oct 20 '11 at 13:18
Good enough for me, if it is not restorable it is not that huge of a problem. It was just a database with me as the only user, it was my learning LDAP server. It would just still suck to have redo everything. LDAP is tedious. – ianc1215 Oct 21 '11 at 4:59

Try this:

sudo ldapadd -Q -Y EXTERNAL -H ldapi:/// -f yourfile.ldif

Should work for Ubuntu 11.10, although I'm still exploring this new cn=config stuff.

share|improve this answer
I don't run with SASL (...yet) so -Q would not help me. – ianc1215 Oct 26 '11 at 4:18

I've used this:

ldapadd -c -x -H ldap://localhost:389 -D "dc=Manager,dc=example,dc=com" -w password -f /tmp/backup.ldif

Modified from

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.