Docker-openldap: Importing config and data from previous OpenLDAP installation

Created on 18 Jan 2017  路  4Comments  路  Source: osixia/docker-openldap

Hi,

I am trying to migrate my OpenLDAP server form a previous (non-dockerised) installation to a dockerised one. On my previous server, I did the following to export the configuration and the users (from serverfault):

slapcat -n 0 -l config.ldif
slapcat -n 1 -l users.ldif

Accoding to the same stop, what I should do on the new server is:

  • Stop the LDAP server;
  • Delete the content of the slapd.d folder;
  • Run slapadd -n 0 -l config.ldif.

Unfortunately, I cannot (or do not know how to) do that with your image. I tried the following:

docker cp config.ldif openldap:/config.ldif
docker exec openldap slapadd -n -0 -l config.ldif

But I get the following:

slapadd: could not add entry dn="cn=config" (line=1):

Which, according to this, is because the slapd service is still running and/or the /etc/ldap/slapd.d folder is not empty.

I am fairly new to docker and certainly not an LDAP expert... Is there a way to import my previous configuration and users into this docker image?

Note: I am using a data volume container for both /var/lib/ldap and /etc/ldap/slapd.d.

Docker Image question

Most helpful comment

Hello,
it's hard with this image because it's a single process container, so if you stop openldap the container stops but this can be done more easily with openldap-backup image:
https://github.com/osixia/docker-openldap-backup

  • start a new openldap-backup container
  • copy the ldif files to /data/backup in the container
  • execute in the container the following commands:
    slapd-restore-config config.ldif
    slapd-restore-data users.ldif

let me know if you have any problem :)

All 4 comments

Hello,
it's hard with this image because it's a single process container, so if you stop openldap the container stops but this can be done more easily with openldap-backup image:
https://github.com/osixia/docker-openldap-backup

  • start a new openldap-backup container
  • copy the ldif files to /data/backup in the container
  • execute in the container the following commands:
    slapd-restore-config config.ldif
    slapd-restore-data users.ldif

let me know if you have any problem :)

Thanx for this entry, it took me hours to figure this way out. This is quite easy and shall really be documented to the image readme. Now its easy to dockerize an already populated installation.

@Boldie I am trying to do the same thing as op here but there is no such command as slapd-restore.

Am i missing something or do i need to take another step first?

I am aware this is pretty old but fingers crossed

Im not really sure what I did, but I think, I used a clean install of the docker container, add my ldif files and then use the restore command. Sure first you need to make a backup of your old installation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doctormacky picture doctormacky  路  6Comments

tobikris picture tobikris  路  4Comments

xd34 picture xd34  路  4Comments

Shriyanshmit picture Shriyanshmit  路  5Comments

taggartgorman picture taggartgorman  路  5Comments