Previous     Contents     Index     DocHome     Next     
Directory Server 5.0 Configuration, Command, and File Reference



Chapter 7   Command-Line Scripts




Introduction

This chapter provides information on the scripts you can use to back up and restore your database. Scripts are a shortcut way of executing the ns-slapd interface commands which are documented in Appendix A "Using the ns-slapd and slapd.exe Command-Line Utilities." In view of the fact that the Perl scripts shipped with iPlanet Directory Server 5.0 have certain specificities, they are dealt with in a separate section. This chapter is divided into the following sections:



Finding and executing Command-Line Scripts

The scripts assume that you want to use the dse.ldif file located in:

/usr/iplanet/servers/slapd-serverID/config

By default all scripts are stored in the following directory:

/usr/iplanet/servers/slapd-serverID

but refer to the Command-Line Scripts Quick Reference table below for the exact location of each script.

When scripts request either a directory name or a file name, always provide the absolute path.



Caution

In order to execute the Perl Scripts you must change directory to the directory where the command-line utilities are stored. Although it is possible to set command path and library-path variables to execute these scripts, this is not the recommended procedure because you run the risk, particularly when you have more than one server version installed, not only of disrupting the correct execution of other scripts and utilities, but also of compromising the security of the system.

The same procedure also applies to the ldapsearch, ldapmodify, ldapdelete and ldif command-line utilities. Perl scripts used for performing routine operations. For more information on these command line utilities see Chapter 6 "Command-Line Utilities."

Please also note that when you are running the Perl scripts on NT machines you must make sure that the path environment variable contains the Perl executable (perl.exe) file. You therefore need to run the scripts from the following directory on NT machines:

\usr\iplanet\servers\bin\slapd\admin\bin





Command-Line Scripts Quick Reference




Table 7-1    Commonly Used Command-Line Shell and Batch Scripts 

Command Line Script

Description

bak2db  

Restores the database from the most recent archived backup.

Located in: /usr/iplanet/servers/slapd-serverID  

db2bak  

Creates a backup of the current database contents.

Located in: /usr/iplanet/servers/slapd-serverID  

db2ldif  

Exports the contents of the database to LDIF.

Located in: /usr/iplanet/servers/slapd-serverID  

getpwenc  

Prints the encrypted form of a password using one of the server's encryption algorithms. If a user cannot log in, you can use this script to compare the user's password to the password stored in the directory.

Located in: /usr/iplanet/servers/slapd-serverID  

ldif2db  

Imports LDIF files to the database.

Runs the slapd (Windows NT) or ns-slapd (Unix) command-line utility with the ldif2db keyword. By default, the script first saves and then merges any existing configuration tree (o=NetscapeRoot) with any files to be imported.

Located in: /usr/iplanet/servers/slapd-serverID  

ldif2ldap  

Performs an import operation over LDAP to the Directory Server.

Located in: /usr/iplanet/servers/slapd-serverID  

monitor  

Retrieves performance monitoring information using the ldapsearch command-line utility.

Located in: /usr/iplanet/servers/slapd-serverID  

restart-slapd  

Restarts Directory Server.

Located in: /usr/iplanet/servers/slapd-serverID  

restoreconfig  

Restores by default the most recently saved Admin Server configuration to NetscapeRoot partition.

Located in: /usr/iplanet/servers/slapd-serverID  

saveconfig  

Saves Admin Server configuration, stored in the NetscapeRoot partition to /usr/iplanet/servers/slapd-serverID/confbak directory.

Located in: /usr/iplanet/servers/slapd-serverID  

start-slapd  

Starts Directory Server.

Located in: /usr/iplanet/servers/slapd-serverID  

stop-slapd  

Stops Directory Server.

Located in: /usr/iplanet/servers/slapd-serverID  

suffix2instance  

Maps a suffix to a backend name.

Located in: /usr/iplanet/servers/slapd-serverID  

vlvindex  

Creates and generates virtual list view (VLV) indexes.

Located in: /usr/iplanet/servers/slapd-serverID  


Table 7-2    Commonly Used Command-Line Perl Scripts

Command Line Perl script

Description

bak2db.pl  

Restores the database from the most recent archived backup.

Located in: /usr/iplanet/servers/slapd-serverID  

db2bak.pl  

Creates a backup of the current database contents

Located in: /usr/iplanet/servers/slapd-serverID  

db2index.pl  

Creates and regenerates indexes.

Located in: /usr/iplanet/servers/slapd-serverID  

db2ldif.pl  

Exports the contents of the database to LDIF

Located in: /usr/iplanet/servers/slapd-serverID  

ldif2db.pl  

Imports LDIF files to database.

Runs the slapd (Windows NT) or ns-slapd (Unix) command-line utility with the ldif2db keyword. By default, the script first saves and then merges any existing configuration tree (o=NetscapeRoot), with any files to be imported.

Located in: /usr/iplanet/servers/slapd-serverID  

migrateInstance5  

Migrates a 4.x version of the Directory Server to the 5.0 version, converting the configuration files to LDIF format.

Located in: /usr/iplanet/servers/bin/slapd/admin/bin  

ns-accountstatus.pl  

Provides account status information to establish whether an entry or group of entries is locked or not.

Located in: /usr/iplanet/servers/slapd-serverID  

ns-activate.pl  

Activates an entry or a group of entries by unlocking it (them).

Located in: /usr/iplanet/servers/slapd-serverID  

ns-inactivate.pl  

Inactivates an entry or a group of entries.

Located in: /usr/iplanet/servers/slapd-serverID  



Shell and Batch Scripts



When running the Shell and Batch scripts the server must be stopped. The majority of Shell and Batch scripts have a Perl equivalent, but this is not always the case.


bak2db(Restore database from backup)

Restores the database from the most recent archived backup.


Syntax

Shell script (UNIX)

bak2db [backup_directory]

Batch file (NT)

bak2db [backup_directory]

For more information on restoring databases see Chapter 3, "Populating Directory Databases" in the iPlanet Directory Server Administrator's Guide.


db2bak (Create backup of database)

Creates a backup of the current database contents. To run this script the server must be stopped.


Syntax

Shell script (UNIX)

db2bak [backup_directory]

Batch file (NT)

db2bak [backup_directory]


db2ldif (Export database contents to LDIF)

Exports the contents of the database to LDIF. For the shell and batch scripts, the script runs the slapd (Windows NT) or ns-slapd (UNIX) command-line utility with the ldif2db keyword.


Syntax

Shell script (UNIX)

db2ldif {-n backend_instance}* | {-s includesuffix}* [{-x excludesuffix}*] [-r] [-C] [-u] [-U] [-m] [M] [-a outputfile] [-1] [-N]

Batch file (NT)

db2ldif {-n backend_instance}* | {-s includesuffix}* [{-x excludesuffix}*] [-r] [-C] [-u] [-U] [-m] [M] [-a outputfile] [-1] [-N]



Note You must specify either the -n or the -s option.




Options




-a  

File name of the output LDIF file.  

-n  

Instance to be exported.  

-s  

Suffix(es) to be included or to specify the subtree(s) to be included if -n has been used.  

-x  

Suffix(es) to be excluded.  

-m  

Minimal base64 encoding.  

-M  

Use of several files for storing the output LDIF with each instance stored in instance_file name (where file name is the file name specified for -a option).  

-N  

Specifies that the entry IDs are not to be included in the LDIF output. The entry IDs are necessary only if the db2ldif output is to be used as input to db2index.  

-r  

Export replica.  

-u  

Request that the unique id is not exported.  

-C  

Only the main db file is used.  

-N  

Specifies that entry IDs are not to be included in the LDIF output. The entry IDs are necessary only if the db2ldif output is to be used as input to db2index.  

-U  

Request that the output LDIF is not folded.  

-1  

Delete, for reasons of backward compatibility, the first line of the LDIF file which gives the version of the LDIF standard.  



Note Please note that by default the output LDIF will be stored in one file. Should you want to specify the use of several files, then use the option -M.




getpwenc (Print encrypted password)

Prints the encrypted form of a password using one of the server's encryption algorithms. If a user cannot log in, you can use this script to compare the user's password to the password stored in the directory.


Syntax

Shell script (UNIX)

getpwenc schemaname clearpassword

Batch file (NT)

getpwenc schemaname clearpassword


Options
There are no options for this script.

For more information on the different types of schema such as SSHA, SHA, CRYPT and CLEAR see the iPlanet Directory Server Administrator's Guide.


ldif2db (Import)

Runs the slapd (Windows NT) or ns-slapd (Unix) command-line utility with the ldif2db keyword. To run this script the server must be stopped.



Note Note that ldif2db supports LDIF version 1 specifications. You can load an attribute using the :< URL specifier notation, for example:

jpegphoto:< file:///tmp/myphoto.jpg

Although the official notation requires three ///, the use of one / is tolerated. For further information LDIF format see Chapter 4, "Managing Directory Entries" in the iPlanet Directory Server Administrator's Guide.




Syntax

Shell script (UNIX)

ldif2db -n backend_instance | {-s includesuffix}* [{-x excludesuffix}*] {-i ldiffile}* [-O] [-g string] [-G namespace_id]

Batch file (NT)

ldif2db -n backend_instance | {-s includesuffix}* [{-x excludesuffix}*] {-i ldiffile}* [-O] [-g string] [-G namespace_id]


Options




-n  

Instance to be imported. Ensure that you specify an instance that corresponds to the suffix contained by the LDIF file because otherwise the data contained by the database is deleted and the import fails.  

-i  

File name of the input ldif file(s). When you import multiple files, they are imported in the order in which you specify them on the command line.  

-s  

Suffix(es) to be included or to specify the subtree(s) to be included if -n has been used.  

-x  

Suffix(es) to be included.  

-O  

Request that only the core db is created without attribute indexes.  

-c  

Merge chunk size.  

-g string  

Generation of a unique ID. Type none for no unique ID to be generated and deterministic for the generated unique ID to be name-based. By default a time based unique ID is generated.

If you use the deterministic generation to have a name-based unique ID, you can also specify the namespace you want the server to use as follows:

-g deterministic namespace_id

where namespace_id is a string of characters in the following format

00-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx

Use this option if you want to import the same LDIF file into two different directory servers, and you want the contents of both directories to have the same set of unique IDs. If unique IDs already exist in the LDIF file you are importing, then the existing IDs are imported to the server regardless of the options you have specified.  

-G namespace_id  

Generates a namespace ID as a name-based unique ID. This is the same as specifying the -g deterministic option.  


ldif2ldap (Perform import operation over LDAP)

Performs an import operation over LDAP to the Directory Server. To run this script the server must be running.


Syntax

Shell script (UNIX)

ldif2ldap -D rootdn -w password -f file name

Batch file (NT)

ldif2ldap -D rootdn -w password -f file name


Options




-D  

User DN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-f  

File name of the file to be imported. When you import multiple files, they are imported in the order in which you specify them on the command line.  


monitor (Retrieve monitoring information)

Retrieves performance monitoring information using the ldapsearch command-line utility.


Syntax

Shell script (UNIX)

monitor

Batch file (NT)

monitor


Options
There are no options for this script.

For more information on the ldapsearch command-line utility see Chapter 6 "Command-Line Utilities".


restart-slapd (Restart the Directory Server)

Restarts the Directory Server.


Syntax

Shell script (UNIX)

restart-slapd

Batch file (NT)

restart-slapd


Options
There are no options for this script.


restoreconfig (Restore Admin Server Configuration information)

Restores, by default, the most recently saved Admin Server configuration information to the NetscapeRoot partition under the following directory:

/usr/iplanet/servers/slapd-serverID/config

To restore the Admin server configuration:

  1. Stop the Directory Server

  2. Run the restoreconfig script

  3. Restart the Directory Server

  4. Restart the Admin Server for the changes to be taken into account


Syntax

Shell script (UNIX)

restoreconfig

Batch file (NT)

restoreconfig


Options
There are no options for this script.


saveconfig (Save Admin Server configuration information)

Saves Admin Server configuration information to the following directory:

/usr/iplanet/servers/slapd-serverID/confbak



Note This script will only run if the server is running.




Syntax

Shell script (UNIX)

saveconfig

Batch file (NT)

saveconfig


Options
There are no options for this script.


start-slapd (Start the Directory Server)

Starts the Directory Server.


Syntax

Shell script (UNIX)

start-slapd

Batch file (NT)

start-slapd


Options
There are no options for this script.


stop-slapd (Stop the Directory Server)

Stops the Directory Server.


Syntax

Shell script (UNIX)

stop-slapd

Batch file (NT)

stop-slapd


Options
There are no options for this script.


suffix2instance (Map a suffix to a backend name)

Maps a suffix to a backend name.


Syntax

Shell script (UNIX)

suffix2instance {-s suffix}

Batch file (NT)

suffix2instance {-s suffix}


Options




-s  

suffix to be mapped to the backend  


vlvindex (Create virtual list view (VLV) indexes)

To run this script the server must be stopped beforehand. The vlvindex script creates virtual list view (VLV) indexes, known in the Directory Server Console as Browsing Indexes. VLV indexes introduce flexibility in the way you view search results. VLV indexes make it possible for you to organize search results alphabetically or in reverse alphabetical order, and to scroll in the list of results. VLV index configuration must already exist prior to running this script.


Syntax

Shell script (UNIX)

vlvindex [-d debug_level] [-n backend_instance] [-s suffix][-T VLVTag]

Batch file (NT)

vlvindex [-d debug_level] -n backend_instance [-s suffix][-T VLVTag]


Options




-d  

Specifies the debug level to use during index creation. Debug levels are defined in "nsslapd-errorlog-level (Error Log Level)".  

-D  

Specifies the server configuration directory that contains the configuration information for the index creation process. You must specify the full path to the slapd-serverID directory.  

-n  

Name of the database containing the entries to index.  

-s  

Name of the suffix containing the entries to index.  

-T  

VLV index identifier to use to create VLV indexes. You can use the console to specify VLV index identifier for each database supporting your directory tree, as described in the iPlanet Directory Server Administrator's Guide. You can define additional VLV tags by creating them in LDIF, and adding them to Directory Server's configuration, as described in the iPlanet Directory Server Administrator's Guide. In any case, we recommend you use the dn of the entry for which you want to accelerate the search sorting.  



Note You must specify either the -n or the -s option.





Perl scripts




bak2db.pl (Restore database from backup)


Syntax

Perl script (Both)

bak2db.pl [-v] -D rootdn -w password -a backup_directory] [-t databasetype]


Options




-D  

User DN with root permissions, such as Directory Manager. The default is the DN of the directory manager which is read from the nsslapd-root attribute under cn=config.  

-w  

Password associated with the user DN.  

-a  

Directory of the backup files.  

-v  

Verbose mode.  

-t  

Database type.  



Note This perl script bak2db.pl creates an entry in the directory that launches this dynamic task. An entry is generated based upon the values you provide for each option.

Also note that for the moment the only possible database type is ldbm.




db2bak.pl (Create backup of database)


Syntax

Perl script (Both)

db2bak.pl [-v] -D rootdn -w password [-a dirname]


Options




-D  

User DN with root permissions, such as Directory Manager. The default is the DN of the directory manager which is read from the nsslapd-root attribute under cn=config.  

-w  

Password associated with the user DN.  

-a  

Directory where the backup files will be stored. By default it is under /usr/iplanet/servers/slapd-serverID/bak

The backup file is named according to the year-month-day-hour format (YYYY_MM_DD_hhmmss).  

-v  

Verbose mode.  

-t  

Database type.  



Note This perl script bak2db.pl creates an entry in the directory that launches this dynamic task. An entry is generated based upon the values you provide for each option.

Also note that for the moment, the only possible database type is ldbm.




db2index.pl (Create and generate indexes)

Creates and generates the new set of indexes to be maintained following the modification of indexing entries in the cn=config configuration file.


Syntax

Perl script (Both)

db2bindex.pl [-v] -D rootdn -w password -n backend_instance [-t attributeName]


Options




-D  

User DN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-n  

Instance to be indexed.  

-t  

Name of the attribute to be indexed. If omitted, all indexes defined for that instance are generated.  

-v  

Verbose mode.  



Note This perl script bak2db.pl creates an entry in the directory that launches this dynamic task. An entry is generated based upon the values you provide for each option.




db2ldif.pl (Export database contents to LDIF)

Exports the contents of the database to LDIF. This Perl script creates an entry in the directory that launches this dynamic task. The entry is generated based upon the values you provide for each option. The * indicates that multiple occurrences are allowed.


Syntax

Perl script (Both)

db2ldif.pl [-v] -D rootdn -w password {-n backend_instance}* | {-s includesuffix}* [{-x excludesuffix}*] [-a outputfile] [-N] [-r] [-C] [-u] [-U] [-m] [-o] [-1] [M]



Caution

To run this script the server must be running and either -n backend_instance or -s includesuffix is required.

This perl script bak2db.pl creates an entry in the directory that launches this dynamic task. An entry is generated based upon the values you provide for each option.




Options




-D  

User DN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-n  

Instance to be exported.  

-a  

File name of the output LDIF file.  

-s  

Suffix(es) to be included or to specify the subtree(s) to be included if -n has been used.  

-x  

Suffix(es) to be excluded.  

-m  

Minimal base64 encoding.  

-o  

Output LDIF to be stored in one file by default with each instance stored in instance_file name.  

-r  

Export replica.  

-u  

Request that the unique id is not exported.  

-C  

Only the main db file is used.  

-N  

Suppress printing sequential number.  

-U  

Request that the output LDIF is not folded.  

-v  

Verbose mode.  

-1  

Delete, for reasons of backward compatibility the first line of the LDIF file that gives the version of the LDIF standard.  

-M  

Output LDIF is stored in multiple files.  


ldif2db.pl (Import)

To run this Perl script the server must be running. This script creates an entry in the directory that launches this dynamic task. The entry is generated based upon the values you provide for each option.


Syntax

Perl script (Both)

ldif2db.pl [-v] -D rootdn -w password -n backend_instance | {-s includesuffix}* [{-x excludesuffix}*] [-O] [-c] [-g string] [-G namespace_id] {-i file name}*


Options




-D  

User DN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-n  

Instance to be imported.  

-i  

File name of the input LDIF file(s). When you import multiple files, they are imported in the order in which you specify them on the command line.  

-s  

Suffix(es) to be included or to specify the subtree(s) to be included if -n has been used.  

-x  

Suffix(es) to be included.  

-O  

Request that only the core db is created without attribute indexes.  

-c  

Merge chunk size.  

-g string  

Generation of a unique ID. Type none for no unique ID to be generated and deterministic for the generated unique ID to be name-based. By default a time based unique ID is generated.

If you use the deterministic generation to have a name-based unique ID, you can also specify the namespace you want the server to use as follows:

-g deterministic namespace_id

where namespace_id is a string of characters in the following format

00-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx

Use this option if you want to import the same LDIF file into two different directory servers, and you want the contents of both directories to have the same set of unique IDs. If unique IDs already exist in the LDIF file you are importing, then the existing IDs are imported to the server regardless of the options you have specified.  

-G namespace_id  

Generates a namespace ID as a name-based unique ID. This is the same as specifying the -g deterministic option.  

-v  

Verbose mode.  



Note This perl script bak2db.pl creates an entry in the directory that launches this dynamic task. An entry is generated based upon the values you provide for each option.




migrateInstance5 (Migrate from 4.x version of Directory Server)

This Perl script (note that this is a Perl script despite the fact that it does not have the .pl extension) migrates the 4.x version of Directory Server to the 5.0 version which includes migrating the configuration files, database instances and schema with minimum manual intervention. The migrateInstance5 script calls on the migrateTo5 script which then executes the migration.

Before performing the migration check that the user-defined variables contain the following associated values, where server5_root is the path to where iPlanet Directory Server 5.0 is installed:

$PERL5LIB

server5_root/bin/slapd/admin/bin

PATH

server5_root/bin/slapd/admin/bin


Syntax

Perl script (Both)

migrateInstance5 -D rootdn -w password -n backend_instance -p port -o 4.xInstancePath -n 5.0InstancePath [-t] [-L]


Options




-D  

Directory Server 5.0 userDN with root permissions, such as Directory Manager.  

-w  

Password associated with the Directory Server 5.0 user DN.  

-p  

Directory Server 5.0 port.  

-o 4.xInstancePath  

Netscape Directory Server 4.x.  

-n 5.0InstancePath  

Path for the new Directory Server 5.0 instance.  

-t  

Trace level. The trace level is set to 0 by default with a valid range of 0 to 3.  

-L  

File in which to log the migration report. By default the migration report is stored under /usr/iplanet/servers/slapd-serverID/logs/Migration_ddmmyyy_hhmmss.log. A sample log might read

/usr/iplanet/servers/slapd-serverID/logs/Migration_20022001_153604.log for a log created on 20 February 2001 at 15.36:04.  


ns-accountstatus.pl (Establish account status)

Provides account status information to establish whether an entry or group of entries is inactivated or not.


Syntax

Perl script (Both)

ns-accountstatus.pl [-D rootdn] -w password [-p port] [-h host] -I DN (to get status of)


Options




-D  

Directory Server 5.0 userDN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-p  

Directory Server 5.0 port. The default value is the LDAP port of Directory Server 5.0 specified at installation time.  

-h  

Host name of Directory Server 5.0. The default value is the full host name of the machine where Directory Server 5.0. is installed.  

-I DN (to get status of)  

Entry DN or role DN whose status is required.  


ns-activate.pl (Activate an entry or group of entries)

Activates an entry or group of entries.


Syntax

Perl script (Both)

ns-activate.pl [-D rootdn] -w password [-p port] [-h host] -I DN (to operation)


Options




-D  

Directory Server 5.0 userDN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-p  

Directory Server 5.0 port. The default value is the LDAP port of Directory Server 5.0 specified at installation time.  

-h  

Host name of Directory Server 5.0. The default value is the full hostname of the machine where Directory Server 5.0. is installed.  

-I DN (to activate)  

Entry DN or role DN to activate.  


ns-inactivate.pl (Inactivate an entry or group of entries)

Inactivates and thus locks and entry or group of entries.


Syntax

Perl script (Both)

ns-inactivate.pl [-D rootdn] -w password [-p port] [-h host] -I DN (to operation)


Options




-D  

Directory Server 5.0 userDN with root permissions, such as Directory Manager.  

-w  

Password associated with the user DN.  

-p  

Directory Server 5.0 port. The default value is the LDAP port of Directory Server 5.0 specified at installation time.  

-h  

Host name of Directory Server 5.0. The default value is the full hostname of the machine where Directory Server 5.0. is installed.  

-I DN (to inactivate)  

Entry DN or role DN to inactivate.  


Previous     Contents     Index     DocHome     Next     
Copyright © 2001 Sun Microsystems, Inc. Some preexisting portions Copyright © 2001 Netscape Communications Corp. All rights reserved.

Last Updated March 23, 2001