3.2. Importing & Exporting Data

You can use the OpenDJ Control Panel to import data (Directory Data > Import LDIF...) and to export data (Directory Data > Export LDIF...). The following procedures demonstrate how to use the import-ldif and export-ldif commands.

Procedure 3.2. To Import LDIF Data

The most efficient method of importing LDIF data is to take the OpenDJ server offline. Alternatively, you can schedule a task to import the data while the server is online.

  1. If you do not want to use the default userRoot backend, create a new JE backend for your data.

    See Section 3.4, “Creating a New Database Backend” for details.

  2. The following example imports dc=example,dc=org data into the userRoot backend, overwriting existing data.

    • If you want to speed up the process—for example because you have millions of directory entries to import—first shut down the server, and then run the import-ldif command.

      $ stop-ds
      $ import-ldif
       --offline
       --includeBranch dc=example,dc=org
       --backendID userRoot
       --ldifFile /path/to/generated.ldif
    • If not, schedule a task to import the data while online.

      $ import-ldif
       --port 4444
       --hostname opendj.example.com
       --bindDN "cn=Directory Manager"
       --bindPassword password
       --includeBranch dc=example,dc=org
       --backendID userRoot
       --ldifFile /path/to/generated.ldif
       --trustAll

      Notice that the task is scheduled through communication over SSL on the administration port, by default 4444. You can schedule the import task to start at a particular time using the --start option.

      The --trustAll option trusts all SSL certificates, such as a default self-signed certificate used for testing.

Procedure 3.3. To Export LDIF Data

  • The following example exports dc=example,dc=org data from the userRoot backend.

    • If you want to speed up export, first shut down the server, and then export data using the export-ldif command.

      $ stop-ds
      $ export-ldif
       --offline
       --includeBranch dc=example,dc=org
       --backendID userRoot
       --ldifFile /path/to/backup.ldif
    • If not, schedule a task to export the data while online.

      $ export-ldif
       --port 4444
       --hostname opendj.example.com
       --bindDN "cn=Directory Manager"
       --bindPassword password
       --includeBranch dc=example,dc=org
       --backendID userRoot
       --ldifFile /path/to/backup.ldif
       --start 20111221230000
       --trustAll

      The --start 20111221230000 option tells OpenDJ to start the export at 11 PM on December 21, 2012.

      If OpenDJ is stopped at this time, then when you start OpenDJ again, the server attempts to perform the task after starting up.