Symas OpenLDAP Knowledge Base

Using slapcat

slapcat

slapcat Man Page

Syntax: slapcat <conf> (-b <baseDN> | -n <dbNum>) [-l <outfile.ldif>] [-o ldif-wrap=no]

Online Use: ✅

  • The slapcat command is used to export a DIT in LDIF format and is used for exporting and backing up directories
  • The slapcat command is the safest and fastest method for database exports and backups
  • Using ldapsearch for exports and backups may exclude critical operational attributes
Option Description
-b <suffix> | -n <DB Num> Specifies either the database suffix or database number to operate upon
-l <filename>.ldif Specify the file to write the output. If not specified, output goes to STDOUT
-o ldif-wrap=no Disables wrapping of long attribute values
# Export a database using the suffix to an LDIF file:
slapcat <conf> -b dc=example,dc=com -l mybackup.ldif

# Export the cn=config database using the DB number (cn=config is always 0) and disable line wrapping
slapcat <conf> -n0 -o ldif-wrap=no -l config-backup.ldif

# Export a database and pipe through gzip to comress the content and write to file
slapcat <conf> -b dc=example,dc=comm | gzip > backup.ldif.gz