Backup LDAP entries with ldapsearch

I have a LDAP instance running the OpenBSD’s ldapd. I installed the openldap-client package so that I get ldapsearch, but there doesn’t seem to be any slapcat-like tool ; which may be used to backup the LDAP content in LDIF format.

Here’s a trick to dump the ldapd content using ldapsearch:

# ldapsearch -x -H ldaps://ldap.tumfatig.net -D "cn=admin,dc=tumfatig,dc=net" -W -b "dc=tumfatig,dc=net" -LLL > ldapd-"`date +%Y%m%d`".ldif

This generates a file in LDIF format which can be used by ldapadd to fill another LDAP instance.
W00t!

Author: Joel Carnat

Technical Architect and SysAdmin @work ; OpenBSD and FOSS @home ; Karate, Kobudō, Jōdō, Bodyweight workout, Photography @hobby

One thought on “Backup LDAP entries with ldapsearch”

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.