Chapter 1. Importing data to Directory Server
Import data from an LDIF file to a Directory Server database using the command line or the web console.
To import data, you must store the LDIF file that you want to import in the /var/lib/dirsrv/slapd-instance_name/ldif/ directory.
1.1. Importing data using the command line while the server is running Copy linkLink copied to clipboard!
To import data while the Directory Server instance is running, use the dsconf backend import command.
When you start an import operation, Directory Server first removes all existing data from the database and, subsequently, imports the data from the LDIF file. Therefore, if the import fails, the server returns no entries or a partial set of entries.
Prerequisites
-
The LDIF file permissions allow the
dirsrvuser to read the file. - The LDIF file to import contains the root suffix entry.
- The suffix and its database, to which you want to import data, exists in the directory.
- The Directory Server instance is running.
- The LDIF file to import uses UTF-8 character set encoding.
Procedure
Optional: By default, Directory Server sets the entry update sequence numbers (USNs) of all imported entries to
0. To set an alternative initial USN value, set thensslapd-entryusn-import-initvalparameter. For example, to set USN for all imported values to12345, enter:dsconf -D "cn=Directory Manager" ldap://server.example.com config replace nsslapd-entryusn-import-initval=12345
# dsconf -D "cn=Directory Manager" ldap://server.example.com config replace nsslapd-entryusn-import-initval=12345Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you copied the file you want to import to
/var/lib/dirsrv/slapd-instance_name/ldif/, reset the SELinux context on that file:restorecon -Rv /var/lib/dirsrv/slapd-instance_name/ldif/example.ldif
# restorecon -Rv /var/lib/dirsrv/slapd-instance_name/ldif/example.ldifCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
dsconf backend importcommand to import data from an LDIF file.For example, to import the
/var/lib/dirsrv/slapd-instance_name/ldif/example.ldiffile into theuserRootdatabase:dsconf -D "cn=Directory Manager" ldap://server.example.com backend import userRoot /var/lib/dirsrv/slapd-instance_name/ldif/example.ldif
# dsconf -D "cn=Directory Manager" ldap://server.example.com backend import userRoot /var/lib/dirsrv/slapd-instance_name/ldif/example.ldif The import task has finished successfullyCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Search the
/var/log/dirsrv/slapd-instance_name/errorslog for problems during the import.
Verification
Search for entries under the imported suffix, for example
dc=example,dc=com:ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "dc=example,dc=com" -s sub -x
# ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "dc=example,dc=com" -s sub -xCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2. Importing data using the command line while the server is offline Copy linkLink copied to clipboard!
If the Directory Server instance is offline, use the dsctl ldif2db command to import data.
When you start an import operation, Directory Server first removes all existing data from the database and, subsequently, imports the data from the LDIF file. Therefore, if the import fails, the server returns no entries or a partial set of entries.
Prerequisites
-
The LDIF file permissions allow the
dirsrvuser to read the file. - The LDIF file to import contains the root suffix entry.
- The suffix and its database, to which you want to import data, exists in the directory.
- The Directory Server instance is not running.
- The LDIF file to import uses UTF-8 character set encoding.
Procedure
Optional: By default, Directory Server sets the entry update sequence numbers (USNs) of all imported entries to
0. To set an alternative initial USN value, set thensslapd-entryusn-import-initvalparameter. For example, to set USN for all imported values to12345, enter:dsconf -D "cn=Directory Manager" ldap://server.example.com config replace nsslapd-entryusn-import-initval=12345
# dsconf -D "cn=Directory Manager" ldap://server.example.com config replace nsslapd-entryusn-import-initval=12345Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you copied the file you want to import to
/var/lib/dirsrv/slapd-instance_name/ldif/, reset the SELinux context on that file:restorecon -Rv /var/lib/dirsrv/slapd-instance_name/ldif/example.ldif
# restorecon -Rv /var/lib/dirsrv/slapd-instance_name/ldif/example.ldifCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
dsctl ldif2dbcommand to import data from an LDIF file. For example, to import the/var/lib/dirsrv/slapd-instance_name/ldif/example.ldiffile into theuserRootdatabase:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Search the
/var/log/dirsrv/slapd-instance_name/errorslog for problems during the import. Optional: Start the instance:
dsctl instance_name start
# dsctl instance_name startCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Search for entries under the imported suffix, for example
dc=example,dc=com:ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "dc=example,dc=com" -s sub -x
# ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "dc=example,dc=com" -s sub -xCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3. Importing data using the web console while the server is running Copy linkLink copied to clipboard!
Directory Server supports importing data using the web console.
When you start an import operation, Directory Server first removes all existing data from the database and, subsequently, imports the data from the LDIF file. Therefore, if the import fails, the server returns no entries or a partial set of entries.
Prerequisites
-
The LDIF file permissions allow the
dirsrvuser to read the file. - The LDIF file to import contains the root suffix entry.
- The suffix and its database, to which you want to import data, exists in the directory.
-
The LDIF file is stored in the
/var/lib/dirsrv/slapd-instance_name/ldif/directory and has thedirsrv_var_lib_tSELinux context set. - The Directory Server instance is running.
- You are logged in to the instance in the web console.
- The LDIF file to import uses UTF-8 character set encoding.
Procedure
- In the web console, open the menu.
- Select the suffix entry.
-
Click , and select
Initialize Suffix. -
Click the button next to the LDIF file you want to import. If the LDIF file is stored in a directory different than
/var/lib/dirsrv/slapd-instance_name/ldif/, enter the full path to the file and click the button. -
Select
Yes, I am sure, and click to confirm. -
To check the log for problems during the import, open the
menu.
Verification
Search for entries under the imported suffix, for example
dc=example,dc=com:ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "dc=example,dc=com" -s sub -x
# ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "dc=example,dc=com" -s sub -xCopy to Clipboard Copied! Toggle word wrap Toggle overflow