General usage of the Replication Server CLI v7

Running Replication Server CLI

You can run the Replication Server CLI from any host on which you can run the Replication Server console. Run the Replication Server CLI by executing the Java runtime program and specifying the following arguments to the Java program:

  • The path to the Replication Server CLI jar file edb-repcli.jar
  • A Replication Server CLI command
  • One or more publication names or subscription names if the command acts on a publication or subscription
  • Parameters and their values that apply to the command

The Java jar file edb-repcli.jar is located in directory XDB_HOME/bin.

Each Replication Server CLI command has the following general syntax:

-command [ { pubname | subname } ...]
         ``[ -parameter [ value ] ...] ...

command is the name of a Replication Server CLI command. The command name must be prefixed by a hyphen character (-). If the command acts on a publication, specify the name of the publication, represented by pubname. If the command acts on a subscription, spcify the subscription name, represented by subname. Some commands might allow you to specify more than one publication name or more than one subscription name.

One or more parameters might follow. Each parameter name must have a hyphen prefix. You might need to specify one or more values for a parameter.

If a command takes more than one parameter, the order in which you specify the parameters makes no difference. Each parameter must be followed only by the values that pertain to it.

Command names and parameter names are all case sensitive and must be given as shown in Getting help.

The general, complete execution syntax that you enter at the command line prompt has the following format:

java -jar XDB_HOME/bin/edb-repcli.jar
  -command [ { pubname | subname } ...]
           [ -parameter [ value ] ...] ...

Enter the syntax as one logical line on the command line. It is broken up into multiple lines in the syntax diagram for the purpose of clarity.

Note

You can continue a command onto the next physical line if you enter the operating system’s continuation character (for example, the backslash character (\) in Linux or the caret character (^) in Windows) before pressing Enter.

Getting help

If you execute the Replication Server CLI with the help command, Replication Server CLI lists a syntax summary of all commands. See Getting help.

Supplying the publication or subscription server login information

Using the parameter repsvrfile is the Replication Server CLI equivalent for the process of registering the publication server or the subscription server in the Replication Server console.

Registering a publication server discusses how the first step in building a replication system is to register the publication server. In the Replication Server console, the registered publication server appears as a node in the replication tree. The Publication Server node provides a context to which you can add other logical components of the replication system.

When using the Replication Server CLI, there's no replication tree image available with which to relate the other logical components of the replication system. Instead, whenever you execute a Replication Server CLI command that requires the context of a publication server or subscription server, you must specify the publication server’s login information or the subscription server’s login information by means of the repsvrfile parameter.

The repsvrfile parameter takes as its value the path to a text file that contains the login information of either the publication server instance or the subscription server instance that you want to use. The general Replication Server CLI command syntax that includes the repsvrfile parameter is shown in the following diagram:

-command [ { pubname | subname } ...]
         [ -parameter [ value ] ...] ...
         [ -repsvrfile repsvrfile ]
         [ -parameter [ value ] ...] ...

The Replication Server CLI command to execute is represented by command. If required, publication names represented by pubname or subscription names represented by subname are specified next. The path to the text file containing either the publication server or subscription server login information is represented by repsvrfile. The parameters and their values that are used with the command are denoted by parameter and value.

The order on the command line in which you give -repsvrfile repsvrfile and -parameter and its values doesn't matter. For example, you can give -repsvrfile repsvrfile as the first parameter on the command line, the last parameter on the command line, or somewhere in between other parameters.

The following is an example of repsvrfile for a publication server:

host=localhost
port=9051
user=admin
# Password is in encrypted form.
password=ygJ9AxoJEX854elcVIJPTw==

The following is an example of repsvrfile for a subscription server:

host=localhost
port=9052
user=admin
# Password is in encrypted form.
password=ygJ9AxoJEX854elcVIJPTw==

You can locate these files in any directory as long as you can read them.

In your file, be sure to replace the values of the following fields with the values for your publication server or subscription server:

  • Host
  • Port
  • User
  • Password

This is the same information you need to register the publication server or subscription server using the Replication Server console. See Registering a publication server and Registering a subscription server.

The following example shows how to use the repsvrfile parameter with the printpublist command.

$ java -jar edb-repcli.jar -printpublist -repsvrfile ~/pubsvrfile.prop
Printing publications ...
analysts_managers
dept_emp
emp_pub

Using encrypted passwords in text files

When you use the Replication Server CLI, text files store certain information, which can include user names and passwords. An example is the files containing publication server and subscription server login information used with the repsvrfile parameter.

In the file specified with parameter repsvrfile, the password field must be set to a password in encrypted form. Using an encrypted password prevents unauthorized personnel from accessing the publication server or subscription server using the values of user and password if the file is compromised. (You can't use the encrypted password to access the publication server or subscription server from the dialog box in the Replication Server console.)

See Encrypting passwords to learn how to generate an encrypted password using the encrypt command.

Running Replication Server CLI using a parameter file

The paramfile command allows you to run a Replication Server CLI command and its parameters that were coded into a text file. This technique is useful if you want to save the command and its parameters for repeated use.

The syntax for executing paramfile is shown by the following:

java -jar XDB_HOME/bin/edb-repcli.jar
  -paramfile cmdparamfile

The syntax of the Replication Server CLI command and its parameters coded into text file cmdparamfile is the same as if given at the command line prompt, as shown by the following:

-command [ { pubname | subname } ...]
         [ -parameter [ value ] ...] ...
         [ -repsvrfile repsvrfile ]
         [ -parameter [ value ] ...] ...

Using the paramfile command has the following restrictions:

  • You can code only one Replication Server CLI command into the parameter file cmdparamfile.
  • The parameters to use with the Replication Server CLI command must all be included in cmdparamfile. You can't code some of the parameters into cmdparamfile and give other parameters on the command line.

The following example creates an EDB Postgres Advanced Server publication database definition using a parameter file named addpubdb_advsvr.

The following is the content of parameter file addpubdb_advsvr:

-addpubdb
  -repsvrfile /home/user/pubsvrfile.prop
  -dbtype enterprisedb
  -dbhost 192.168.2.4
  -dbport 5444
  -dbuser pubuser
  -dbpassword ygJ9AxoJEX854elcVIJPTw==
  -database edb
  -repgrouptype s

For Windows only: You can specify the -repsvrfile directory path with either the forward slash or backslash character. Enclose the entire directory path in double quotation marks if a directory name contains space characters:

-addpubdb
  -repsvrfile "C:\Users\User Name\repcli\pubsvrfile.prop"
  -dbtype enterprisedb
  -dbhost 192.168.2.23
  -dbport 5444
  -dbuser pubuser
  -dbpassword ygJ9AxoJEX854elcVIJPTw==
  -database edb
  -repgrouptype s
Note

Unlike entering the Replication Server CLI command and its parameters directly at the command line prompt, when coded into a text file, no continuation characters are needed to continue onto the following lines.

The following shows executing the paramfile command:

$ java -jar edb-repcli.jar -paramfile ~/addpubdb_advsvr
Adding Publication Database...
Publication database added successfully. Publication Database id:1

Testing the command exit status

After executing a Replication Server CLI command, you can test the exit status to determine if the command was successful.

An exit status of 0 indicates success. A non-zero exit status indicates a failure has occurred.

For Linux only: The environment variable $? contains the exit status. The following example shows the 0 exit status upon the successful execution of the addpubdb command contained in the addpubdb_advsvr parameter file. See Running Replication Server CLI using a parameter file.

$ java -jar edb-repcli.jar -paramfile ~/addpubdb_advsvr
Adding publication database...
Publication database added successfully. Publication database id:1
$ echo $?
0

The following example shows a non-zero exit status when the command failed with an error.

Exit statusDescription
0Success
201Invalid command
202I/O error
203Decryption failed
204Authentication failed
205Publication service failure
206Remote exception
207Subscription service failure
$ java -jar edb-repcli.jar -paramfile ~/addpubdb_advsvr
Adding publication database...
Error:The connection attempt failed.
$ echo $?
200

For Windows only: The environment variable %ERRORLEVEL% contains the exit status.

The following shows the exit status upon successful command execution on a Windows system.

C:\Users>java -jar C:\\"Program Files"\edb\EnterpriseDB-xDBReplicationServer\bin\edb-repcli.jar -paramfile addpubdb_advsvr
Adding publication database...
Publication database added successfully. Publication database id:1

C:\Users>ECHO %ERRORLEVEL%
0

The following shows the exit status upon unsuccessful command execution on a Windows system.

C:\Users>java -jar C:\\"Program Files"\edb\EnterpriseDB-xDBReplicationServer\bin\edb-
repcli.jar -paramfile addpubdb_advsvr
Adding publication database...
Error:FATAL: password authentication failed for user "myuser"

C:\Users>ECHO %ERRORLEVEL%
200