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 can be used for exporting and backing up directories
  • slapcat is a safe but relatively slow method for database exports and backups
  • slapcat produces an accurate LDIF output of the contents of the directory.
  • A faster and highly recommended way to back up an mdb database is the mdb_copy command as it is much faste and just as safe
  • Using ldapsearch for exports and backups may exclude critical operational attributes and SHOULD NOT be used.
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