ReplicatorCLI is a command line tool used for executing database replication jobs via scripts. It's also called internally by the related functions within the ZeeBORN application.

## Export

The parameter `-export` is used for creating regular transfer files for all active vessels/sites that hava the automatic data transfer option enabled (see also [Selecting Sites for Export](#selecting-sites-for-export)).

## Document Export

The parameter `-docexport` is used for creating the transfer files used for updating the content of the Documents module.
By default all changes and new entries added to the database after creating the previous transfer will be included in the transfer file(s). The transfer files will be created for all active vessels/sites (see also [Selecting Sites for Export](#selecting-sites-for-export)).

!!!WARNING Important
The document transfer files created with the ReplicatorCLI tool contain only the current releases of documents to be transmitted. Obsolete or archived document versions won't be included in the transfer file.
If you need to send all versions of available documents (incl. obsolete and archived), you will need to use the `Send Update` option in the [Documents](/HSSEQ/Document-Management/Document-Library.md#updating-distribution-of-updates) module.
!!!

!!!INFO
The `-export` and `-docexport` options cannot be used at the same time.
!!!

### Export Options

Parameter `-recover [date]/[days]` can be used for creating a recover transfer. All changes and new entries added to the database after the given date will be included in the transfer file. 
The date must be given in format `yyyy-mm-dd`. 

Instead of using a date, a numerical value can be provided and the start date will be calculated by substracting the value (as number of days) from the current system date.

Parameter `-full` can be used for creating the initial data transfer file for a new vessel/site. The created transfer file includes all data available in the database. Full transfers can be used for initializing databases after a fresh installation of the software or for restoring a database after a loss of the database.

### Selecting Sites for Export

The options described below are only available for sending transfer files from the office to other sites. 

Using the tool on board or on a site system will always create a transfer file to be sent to the office. Using the `-imono` parameter and the auto-transfer options will be ignored.

#### Auto-Transfer Option

By default all sites/vessels with an active license and active auto-transfer option will be processed during the creation of transfer files.

For setting the auto-transfer option the command `zeeborn -replicatorconfig` can be used from the command line for selecting sites to be (de)activated.

#### Using the -imono Parameter

The parameter `-imono [imono[,imono]]` can be used for limiting the export to the site(s) identified via the given IMO number. Multiple IMO numbers can be specified with a comma delimited list.

!!!INFO
While using the `-imono` can also be used for creating transfer files that have the auto-transfer option not set, still an active license for the destination site is required.
!!!

## Import

The parameter `-import [folder/replic-file]` can be used for importing transfer files.
The `-import` parameter must be followed by the path where the transfer files to be imported are located. All available .replic files found in this folder and its sub-folders will be imported.

Instead of providing an import folder as parameter, a single .replic file name can be used for direct import.

!!!TIP
After a successful import the file extension of `.replic` files will be changed to `.imported`.

If problems are detected during the import, the file extension will be changed to `.failed`. Usually this requires to check the available log files for potential error sources and initiating a recover transfer at the sending site.

Use parameter `-keepfailed` to prevent any changes to the file extensions.
!!!

## Parameter Overview

-export
:   Create a regular export (changes since last export) for all active and configured sites.

-import
:   Import single data replication files or entire folders with replication files. The `-import` parameter must always be followed by a file name or a folder name.

-docexport
:   Create a regular document export (changes since last export) or all sites

-imono
:   Limit the export to a single or multiple sites by providing a single IMO number or a list of comma-separated IMO numbers

-recover
:   Creates a recover transfer. The `-recover` parameter must always be followed by
    start date (format yyyy-mm-dd) since when changes and new data are to be exported.

-full
:   Creates a full data replication file for sending all data to another site as a disaster recovery option.    

## Examples

### Creating a recover transfer for a selected site

```
replicatorcli -export -recover 2023-01-01 -imono 1234567
```

This command creates a recover transfer for site identified via IMO number "1234567" including all new records and changes after 1st of January 2023.

```
replicatorcli -export -recover 7 -imono 1234567
```

This command creates a recover transfer for site identified via IMO number "1234567" including all new records and changes from the last 7 days.

### Importing transfer files

```
replicatorcli -import "c:\zeeborndata\replication files\download"

replicatorcli -import "{zeebornshared}\replication files\download"

```

`{zeebornshared}` shown in the 2nd example will automatically be replaced with the current shared network folder configured in the system.

### Creating a regular documents export

```
replicatorcli -docexport
```

Creates a transfer files with updates for the Documents module containing all new records and changes after the last transfer file creation.

### Creating a recover documents export

```
replicatorcli -docexport -recover 2023-01-01
```

Creates a recover transfer for Documents module starting with new and added data since 1st of January 2023.

```
replicatorcli -docexport -recover 30
```

Creates a recover transfer for Documents module starting with new and added data from the last 30 days.

### Creating a full document export

```
replicatorcli -docexport -full -imono 1234567
```

Creates a full transfer for Documents module for site with IMO no. 1234567. This type of export can be used as a disaster recovery option.

## Additional Parameters

The tool supports some additional parameters that are mainly used for system maintenance and for transfer automation via related scripts.

-list
:   Shows a list of all sites that are available for data replication. Sites with a `(*)` marker are configured for automatic transfer.

-sftpconfig
:   Shows configuration info for verification.

-sftptest
:   Tests the connection to the configured transfer server.

-upload 
:   Uploads all previously created transfer files to the transfer server. Only transfer files for sites configured for automatic data transfer will be uploaded.

-download
:  Downloads all transfer files from the transfer server. Only transfer files for sites configured for automatic data 
transfer will be downloaded.

-wait
:  Waits for a keypress after finishing the operation. 

*[PO]: Purchase Order  
*[AZA]: local folder
*[(PO]: Purchase Order  
*[RQ]: Requisition  
*[(RQ]: Requisition  
*[RfQ]: Request for Quotation  
*[(RfQ]: Request for Quotation  
*[SO]: Service Order  
*[(SO]: Service Order  
*[SQ]: Service Requisition  
*[(SQ]: Service Requisition  
*[SRfQ]: Service Request for Quotation  
*[OoB]: Open on Board  
*[(OoB]: Open on Board 
*[ART]: Average Running Time (operation hours per day) 
*[MC]: Master Contract
*[ADS]: Advantage Database Server (database engine used in previous versions of the ZeeBORN software)
*[.replic]: file extension for replication files (aka data transfer files)
