# Recover openLDAP database from broken system

## hajokries

I had to reinstall gentoo on an old server running openLDAP, samba, nfs-mount etc. I backuped the root disk before but now I have problems to recover the old ldap database (*.gdbm files). I am new to gentoo and quite helpless...

My slapd.conf:

```
include         /etc/openldap/schema/core.schema

include         /etc/openldap/schema/cosine.schema

include         /etc/openldap/schema/inetorgperson.schema

include         /etc/openldap/schema/nis.schema

pidfile         /var/run/openldap/slapd.pid

argsfile        /var/run/openldap/slapd.args

modulepath      /usr/lib/openldap/openldap

moduleload      back_hdb.so

access to dn.base="" by * read

access to dn.base="cn=Subschema" by * read

access to *

        by self write

        by users read

        by anonymous auth

database        hdb

replogfile      /var/lib/openldap-slurp/replica/slurpd.replog

replica         host=zzz.yyy.ch:389

                suffix="dc=xxx,dc=yyy,dc=ch"

                binddn="cn=admin,dc=xxx,dc=yyy,dc=ch"

                credentials=******

                bindmethod=simple

suffix          "dc=xxx,dc=yyy,dc=ch"

#              <kbyte> <min>

checkpoint      32      30

rootdn          "cn=admin,dc=xxx,dc=yyy,dc=ch"

rootpw          {SSHA}ofYX2e2sCJdkT0GXSRUgh9PAtQAS1kCK

directory       /var/lib/openldap-ldbm

index   objectClass     eq
```

I do not really understand how slurpd works. I have just seen that all our user data are in the slurpd.replog file. That's why I added this replica section in slapd.conf. Can I get them out of there? Or can I use slapcat to convert those *.gdbm files in openldap-ldbm to ldif's?

On ldapsearch I get this (the database files are in the specified folder):

```
xxx lib # ldapsearch

# extended LDIF

#

# LDAPv3

# base <> with scope subtree

# filter: (objectclass=*)

# requesting: ALL

#

# search result

search: 2

result: 32 No such object

# numResponses: 1
```

Thanks for all your help!

----------

## Mike Hunt

try 

```
ldapsearch -x -D "cn=admin,dc=xxx,dc=yyy,dc=ch" -W
```

if your database is there you can generate an LDIF file with slapcat.

----------

## hajokries

Thanks! You are right. Seems that my access settings in slapd.conf require the authentication.

With 

```
ldapsearch -x -D "cn=admin,dc=xxx,dc=yyy,dc=ch" -W
```

I get all the "test" entries that I made after the reinstallation:

```
...

# my-name, xxx.yyy.ch

dn: cn=my-name,dc=xxx,dc=yyy,dc=ch

objectClass: organizationalRole

cn: my-name

# my system, xxx.yyy.ch

dn: ou=my system,dc=xxx,dc=yyy,dc=ch

objectClass: organizationalUnit

ou: my system

description: Test organizational unit to hold admin user

# mr admin, my system, xxx.yyy.ch

dn: cn=mr admin,ou=my system,dc=xxx,dc=yyy,dc=ch

objectClass: person

userPassword:: dGVzdHBhc3M=

description: mr admin test user

cn: mr admin

sn:: YWRtaW4g

# search result

search: 2

result: 0 Success

# numResponses: 8

# numEntries: 7
```

but nothing that is in the old *.gdbm files.

After

```
slapcat -l /root/slapcat.ldif
```

,

the slapcat.ldif file contains the same 7 entries that I see with ldapsearch but none of the old ones.

The folder /var/lib/openldap-ldbm contains those files:

```

-rw-r--r--  1 ldap ldap        0 Sep 27 18:00 .keep_net-nds_openldap-0

-rw-r--r--  1 ldap ldap      921 Sep 28 20:43 DB_CONFIG

-rw-------  1 ldap ldap    24576 Sep 28 23:48 __db.001

-rw-------  1 ldap ldap   155648 Sep 28 23:48 __db.002

-rw-------  1 ldap ldap   270336 Sep 28 23:48 __db.003

-rw-------  1 ldap ldap    98304 Sep 28 23:48 __db.004

-rw-------  1 ldap ldap   352256 Sep 28 23:48 __db.005

-rw-------  1 ldap ldap    24576 Sep 28 23:48 __db.006

-rw-r--r--  1 ldap ldap     4096 Sep 29 12:18 alock

-rw-------  1 ldap ldap   204800 Sep 27 18:00 cn.gdbm

-rw-------  1 ldap ldap    96252 Sep 27 18:00 displayName.gdbm

-rw-------  1 ldap ldap     8192 Sep 27 22:43 dn2id.bdb

-rw-------  1 ldap ldap     8192 Sep 29 00:32 dn2id.dbb

-rw-------  1 ldap ldap    78366 Sep 27 18:00 dn2id.gdbm

-rw-------  1 ldap ldap    13956 Sep 27 18:00 gidNumber.gdbm

-rw-------  1 ldap ldap    32768 Sep 27 22:43 id2entry.bdb

-rw-------  1 ldap ldap     8192 Sep 29 00:32 id2entry.dbb

-rw-------  1 ldap ldap   711979 Sep 27 18:00 id2entry.gdbm

-rw-------  1 ldap ldap 10485760 Sep 28 23:48 log.0000000001

-rw-------  1 ldap ldap    12384 Sep 27 18:00 memberUid.gdbm

-rw-------  1 ldap ldap     8192 Sep 29 00:32 nextid.dbb

-rw-------  1 ldap ldap    12296 Sep 27 18:00 nextid.gdbm

-rw-------  1 ldap ldap     8192 Sep 29 00:32 objectClass.dbb

-rw-------  1 ldap ldap    26636 Sep 27 18:00 objectClass.gdbm

-rw-------  1 ldap ldap    12320 Sep 27 18:00 sambaDomainName.gdbm

-rw-------  1 ldap ldap    13628 Sep 27 18:00 sambaPrimaryGroupSID.gdbm

-rw-------  1 ldap ldap    14580 Sep 27 18:00 sambaSID.gdbm

-rw-------  1 ldap ldap    49152 Sep 27 18:00 sn.gdbm

-rw-------  1 ldap ldap    94492 Sep 27 18:00 uid.gdbm

-rw-------  1 ldap ldap    14596 Sep 27 18:00 uidNumber.gdbm
```

The new entries seem to be in *.dbb files, the old ones are in *.gdbm files. How can I reactivate this file format?

Thanks!

----------

