HP-UX Directory Server Administrator Guide HP-UX Directory Server Version 8.1 (5900-3098, May 2013)

4.2.3 Exporting to LDIF from the command line
There are three methods for exporting data through the command line:
Using db2ldif
This method runs the command-line utility; unlike the import script, ldif2db, this utility can
be run while the server is running.
Using db2ldif.pl
This Perl script behaves the same as the db2ldif command-line utility and takes the same
options.
Creating a cn=tasks entry
This method creates a temporary task entry that automatically launches an export operation.
This is functionally like running db2ldif, with one exception: when running db2ldif or
db2ldif.pl for a replica (with a -r option, the server must be stopped first. The cn=tasks
entry can be added and export replica information while the server is still running. See
“Exporting through the cn=tasks entry” (page 159).
4.2.3.1 Exporting a database using db2ldif or db2ldif.pl
Databases can be exported to LDIF using the db2ldif command-line script or the db2ldif.pl
Perl script. Both these tools export all the database contents or a part of their contents to LDIF when
the server is running or stopped.
These script take the same options.
NOTE:
The -E option is required to export a database that has been encrypted. For more information,
see “Exporting and importing an encrypted database” (page 51).
NOTE:
If the database being exported is a replica, then the server must be stopped before the export
script is run and the export script must have the -r.
To export to LDIF from the command line:
1. Run either the db2ldif command-line script or the db2ldif.pl Perl script. For example:
/opt/dirsrv/slapd-instance_name/db2ldif -n database1 -a /home/files/output.ldif
This exports the database contents to /home/files/output.ldif. If the -a option is not
specified, then the database information is exported to
/var/opt/dirsrv/slapd-instance_name/ldif/instance_name-database1-date.ldif.
For example:
db2ldif -n database1
It is also possible to specify which suffixes to export, using the -s option. For example:
db2ldif -s "dc=example,dc=com"
The LDIF file in this case would be
/var/opt/dirsrv/slapd-instance_name/ldif/instance_name-example-2009_04_30_112718.ldif,
using the name of the suffix rather than the database.
If the suffix specified is a root suffix, such as dc=example,dc=com, then it is not necessary
to specify the database or to use the -n option.
For more information about using these scripts, see the HP-UX Directory Server configuration,
command, and file reference.
158 Populating Directory Databases