Main menu

Backup and restore 389 Directory server

It’s easy to backup and restore 389 directory server with 389 graphical console. But many times you want to backup a server which don’t have GUI installed on it or you just want to automate the backup process with crontab. 389-DS provides many utilities for backup and restore 389 Directory server.

db2bak and bak2db: This is scripts backup and restore the server while the server is running or stopped.
db2bak.pl and bak2db.pl: It’s an perl version of backup but it must require that server is running. The script creates an entry in the directory that launches as a dynamic task.
db2ldif and ldif2db: While other scripts create a binary backups this scripts can backup and restore directory server in LDIF format.
Let’ see backup and restore 389 Directory server with examples.

Backup 389 Directory server

Backup 389 Directory server using db2bak

# db2bak -Z  dirsrv-base16
  • -Z : Your instance name if you don’t know your instance name you can find it at /var/lib/dirsrv/<your_instance_name>

It will create backup under /var/lib/dirsrv/<your_instance_name>/bak/

Backup 389 Directory server using db2bak.pl perl script

# db2bak.pl  -Z  your_instance_name -D  'cn=directory manager'  -w  password -a /home/LDAP_Backup -P LDAPI
  • -Z : Your instance name if you don’t know your instance name you can find it at /var/lib/dirsrv/<your_instance_name>
  • -D : Your root DN, it can be different if you have changed it during installation.
  • -w : password of your directory manager.
  • -a : your backup location. It’s create backup under /var/lib/dirsrv/<your_instance_name>/bak/ and symlink to your backup directory.

Backup 389 Directory server using db2ldif in LDIF format

db2ldif -Z your_instance_name -n userRoot -a /LDAP/ldif/export.ldif
  • -n : The name of the LDBM database to reindex.  Example: userRoot
  • -a : Export file location

Restoring 389 Directory server

Restoring 389 Directory server using bak2db

Using the bak2db command-line script. This script requires the server to be shut down.

# stop-dirsrv
# bak2db /var/lib/dirsrv/instance_name/bak/instance-2016_03_16_13_47_37/
# start-dirsrv

Restoring 389 Directory server using bak2db.pl perl script

Using the bak2db.pl Perl script. This script works while the server is running.

# bak2db.pl -D "cn=Directory Manager" -w password -a /var/lib/dirsrv/instance_name/bak/instance-2016_03_16_13_47_37/

Restoring 389 Directory server using bak2ldif

# ldif2db -s "dc=example,dc=com" -i /LDAP/ldif/data.ldif

There many way you can customize all this basis on your requirement. Always check man pages for more information.

  • Anand

    Hi,

    We are running 389 ldap server on one server (This is on RHEL6.5) Now we want to restore this server to another server.

    We have setup new server with 389 LDAP server installation complete (RHEL7.2). Now we want to restore only data from RHEL6 server (users and group etc..). Here we do not want to change host name of this server.

FacebookTwitterGoogle+RSS