[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Converting 2.0.x databases to 2.1.x.. without LDIFs



> -----Original Message-----
> From: owner-openldap-software@OpenLDAP.org
> [mailto:owner-openldap-software@OpenLDAP.org]On Behalf Of Keith

> Hello
>    I have recently upgraded my linux version, and in
> the process openldap went from 2.0.27-2.7.3 to
> 2.1.22-8. I sadly did not dump my openldap databases
> to LDIF beforehand with slapcat (that little system
> upgrade detail was lost in the sea of upgrade
> information). So now im stuck with 2.0.x gdbm
> databases that I need to convert to openldap 2.1
> format...
>
> In the quest to make this happen I tried to apply this
> 2.1 command that appears to be for converting 2.0 gdbm
> (But I reserve the right to be very very wrong in that
> observation): slapadd-slapd-2.0-gdbm

Since this tool was not provided by the OpenLDAP project, I can't be certain
of its purpose, but I note that "slapadd" is used for adding entries to
databases. "slapcat" is used for dumping their contents. See if you have a
corresponding slapcat tool available.

> slapadd-slapd-2.0-gdbm -d -1 -f
> /etc/openldap/slapd.conf
> ...lots of debugging output...then...
> slapadd-slapd-2.0-gdbm startup: initiated.
> backend_startup: starting database
> => ldbm_cache_open(
> "/var/lib/ldap/test.com/id2entry.gdbm", 18, 600 )
> ldbm_cache_open (blksize 4096) (maxids 1022)
> (maxindirect 9)
> <= ldbm_cache_open (opened 0)
> ...then it frustratingly hangs and does nothing.

If it's really just a copy of slapadd, then it hasn't hung, it's just waiting
for you to enter some input, since its purpose is to take your input and
store it in a database...

The 2.0 database format is trivial. You can dump it out without slapcat if
you really need to, just using pure gdbm:

/* gdbmcat.c - Copyright 1999,2001 Howard Chu, Symas Corp. */
#include <stdio.h>
#include <gdbm.h>

main(int argc, char *argv[])
{
        datum key, data;
        GDBM_FILE db;
        int *ids;

        if (!argv[1])
        {
                fprintf(stderr, "usage: %s <dbname>\n", argv[0]);
                exit(1);
        }
        db = gdbm_open(argv[1], 0, GDBM_READER
#ifdef GDBM_NOLOCK
        | GDBM_NOLOCK
#endif
        , 0600, 0);
        if (db == NULL)
                exit(2);

        for(key = gdbm_firstkey(db); key.dptr; key = gdbm_nextkey(db, key))
        {
                data = gdbm_fetch(db, key);
                ids = key.dptr;
                printf("Key: %d,%d\n", ids[0], ids[1]);
                printf("%s", data.dptr);
        }
        gdbm_close(db);
}

Compile this and run it on your id2entry file. You'll need to replace the
"Key:" lines with blank lines, but otherwise the output will be regular LDIF
data.

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support