How do I clone an OpenLDAP database

Viewed 91691

I know this is more like a serverfault question than a stackoverflow question, but since serverfault isn't up yet, here I go:

I'm supposed to move an application from one redhat server to another, and without very good knowledge of the internal workings of the application, how would I move the OpenLDAP database from the one machine to the other, with schemas and all.

What files would I need to copy over? I believe the setup is pretty standard.

6 Answers

Some appointments:

  • Save your personalized schemas and objectclasses definitions on your new server. You can look for your included files at slapd.conf to obtain it, for example (this is a part of my slapd.conf):

    include /etc/ldap/schema/core.schema

  • Include your personalized schemas and objectclasses in your new openLDAP installation.

  • Use slapcat command to export your full LDAP tree to a single/various ldif files.

  • Use ldapadd to import the ldif files on to your new LDAP installation.

I prefer copy the database through the protocol:

first of all be sure you have the same schemas on both servers.

  • dump the database with ldapsearch:

    ldapsearch -LLL -Wx -D "cn=admin,dc=domain" -b "dc=domain" > domain.ldif
    
  • and import it in the new server:

    ldapmodify -Wx -D "cn=admin,dc=domain" -a -f domain.ldif
    

in one line:

ldapsearch -LLL -Wx -D "cn=admin,dc=domain" -b "dc=domain" | ldapmodify -w pass -x -D "cn=admin,dc=domain" -a

By using the bin/ldap* commands you are talking directly with the server while using bin/slap* commands you are dealing with the backend files

Related