July 19, 2008

backup databases with ldapsearch example

everytime that I have to do that,  I do a search and never find exactally what I am looking for.

So let me be a page for that.

I’m moving a database from a stinking mandriva to nicer debian/ubuntu

slapcat ldbmsomething either does not work or cannot be installed (I did mention that it was a stinking mandriva, right?)

so LDAPSEARCH FTW!

the parameters:

-x is for simple auth

LLL is for a easier to import format

-D is the auth dn

-b is the base of the search (without that it gives bad “No such object (32)” errors)

-w is a password on the command line (-W instead asks for a password)

-h is the hostname as always

ldapsearch -xLLL -D ‘cn=root,dc=example,dc=com’ -b “dc=example,dc=com” “(objectclass=*)” -w super_secret_password  -h server_name > dump.ldiff

to add again on the other server

ldapadd -x -D ‘cn=root,dc=example,dc=com’ -w super_secret_password  -h other_server_name -f  dump.ldiff