9

Is it possible to export all the data inside openldap for example using ldapsearch or some other tool to a (ldif?) file and then import everything on another server and put this in a script that would be run every day. So that I could use the other one as a backup when the first/master server is not available?

I have full access to the first/master server, but I can't modify it's configuration so I think I can't set up replication.

1 Answer 1

15

Is it possible to export all the data inside openldap for example using ldapsearch or some other tool to a (ldif?) file

Sure, it is possible. slapcat/slapadd is what you're looking for:

slapcat -f /path/to/the/slapd.conf -l backup.ldif
slapadd -v -c -l backup.ldif -f /path/to/the/slapd.conf 

These are basically offline tools, you should stop slapd before proceeding. Maybe you also have to set/fix file permissions after restore.

4
  • Thanks, that looks just what I needed. I was just wondering if I can do it over and over - I mean do I have to purge the ldap database on the backup server before I do the slapadd command or it doesn't matter?
    – Jure1873
    Oct 5, 2012 at 15:35
  • 2
    Yes. You must stop the slapd first, and delete old database rm -fr /var/lib/ldap/* then restore. If not, you'll get something like Key/data pair already exists (-30996).
    – quanta
    Oct 5, 2012 at 15:45
  • Ok, I will do that.
    – Jure1873
    Oct 5, 2012 at 15:49
  • 2
    in OpenLDAP 2.4+ you probably want to use slapcat -F /etc/openldap/slapd.d for the new dynamic configuration operation. Aug 11, 2020 at 12:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .