Skip to main content

mercury-transfer: copying cases between instances

Info

mercury-transfer copies the cases of one type (with the definition of the type) from a source instance to a target instance of Mercury DB (HgDB) 3.0. It connects to two running instances through web services and needs no access to their databases. This article describes how to run it, how it works and how to configure it.

Running​

The script mercury-transfer.sh is in the directory bin of the installation package; it finds the installation directory itself and reads the configuration from ../config. In the Docker image of the server it is in /opt/mercury-3.0/bin.

mercury-transfer.sh --type Invoice
mercury-transfer.sh -t Invoice -s A -q 'mrc_Case_id:1*' --config ../config/transfer.properties
OptionMeaning
-t, --type <type>Required. Code of the type of the cases
-s, --state <state>Only the cases in this state: N (finished), A (active), O (postponed), Z (interrupted). By default all states
-q, --query <query>An additional condition of the Lucene query that is appended to the query of the source cases
--config <file>The configuration file (by default ../config/transfer.properties)
--lang <code>The language of the help and the messages
-h, --help, -V, --versionHelp and version

Exit codes​

CodeMeaning
0the transfer ended without an exception
1no connection to one of the instances, or the transfer ended with an exception (see the log)
2wrong arguments (the help or the reason is printed)

Errors of single pages do not change the exit code: they are written to the log, see How it works.

Language​

The help and the messages are printed in the first language that is set in this order: the option --lang <code> (for example --lang de), the environment variables LC_ALL, LC_MESSAGES, LANG (for example pl_PL.UTF-8; C and POSIX mean English), the language of the JVM, English. The scripts of the installation package set LANG and LC_ALL to pl_PL.UTF-8; change them in the script or give --lang.

How it works​

  1. The tool reads the configuration and checks the connection to both instances (the service echo). When one of them does not answer, it ends with the code 1.
  2. It transfers the definition of the type: the type with its subtypes (recursively) and the parameter definitions. A subtype without a definition in the source is skipped, and the link to it is removed.
  3. It searches the source for the cases with the query +<type>:<code> [+status:<state>] [<additional condition>], divides the result into pages and transfers the pages in many threads: every thread reads a page from the source and saves the cases in the target.
  4. The tool only writes to the target: it deletes nothing.

An error of a page is written to the log together with the identifiers of the cases that were not transferred (Lost caseIds), and the transfer goes on with the other pages. After the run read the log of the tool (logs/mercury-cmd.log in the installation directory, configured in logback.xml).

Configuration: config/transfer.properties​

The instances are called source and target; the name list is required (without it the tool reports that the service is not in the list of declared services).

mercury.cmd.name=mercury-transfer
mercury.lucene.model.version=2
mercury.ws.service.list=source,target

transfer.maxThreads=10
transfer.pageSize=100
source.maxResults=1000
source.maxDepth=8

source.ws.url=http://source-node.example.com:8080/mercury-ws-app/remoting
source.ws.security.enabled=false
source.ws.security.identifier=cxf
source.ws.security.token=secret

target.ws.url=https://target.example.com/mercury-ws-app/remoting
target.ws.security.enabled=true
target.ws.security.identifier=mercury
target.ws.security.token=<the token of the target>
PropertyMeaning (default when not set)
mercury.lucene.model.versionVersion of the model of the search index of the source (2 or 3); it decides the names of the fields in the query
mercury.ws.service.listNames of the service instances: source,target
transfer.maxThreadsNumber of threads (5)
transfer.pageSizeNumber of cases on a page (100)
source.maxResultsThe largest number of cases of the source that one query returns (10000)
source.maxDepthThe depth of the cases that are read (8)
<instance>.ws.urlThe address of the services remoting of the instance
<instance>.ws.security.enabled, .identifier, .tokenAuthentication to the services of the instance
Personal data and tokens

The file contains the tokens of the services, and the transferred cases can contain personal data. Protect the file and the logs of the transfer like the data of the system.

See also: mercury-cmd.