This example sets up replication in one direction between two SQL Server databases. The Capture Process reads the changes of the Source Database and the Apply Process applies them to the Target Database. The commands are typed in repcli. The same configuration can be made in the Web UI (see Setup First Replication) or with the REST API.
Connect to the Repstance server (see Getting Started with Repstance) and run repcli. It starts in Fully Interactive Mode and shows its prompt, the address of the Repstance server and repcli>:
[http://localhost:8796/] repcli>The commands below are typed after the prompt, which is written repcli> in the examples. Press the Tab key to see the possible commands and parameters.
The Capture Process needs a few objects in the Source Database. The command prepare database creates them (see Prepare Source Database). database=source says that the objects of a Source are created, dbtype=mssql is the type of the database and the other parameters are the connection:
repcli>prepare database=source dbtype=mssql server=db-src.example.com port=1433 user=repuser password=Passw0rd123 dbname=testDB
[Completed]: Database [db-src.example.com:1433,testDB] has been prepared.To check a database without changing it, use validate (see Validate Database).
The Capture Process reads the changes of the Source Database and writes them to trail files. id=1 is the number of the process: it is used to run, stop, change or remove it. name=rep1 is the name that the Apply Processes use to read from this Capture Process. dmlinclude=dbo.% and ddlinclude=dbo.% select the tables whose data changes (DML) and whose structure changes (DDL) are replicated: all the tables of the schema dbo, the % symbol matches any number of characters (see Capture Objects Specification and Prepare Capture Process):
repcli>prepare process=capture id=1 dbtype=mssql name=rep1 server=db-src.example.com port=1433 user=repuser password=Passw0rd123 dbname=testDB dmlinclude=dbo.% ddlinclude=dbo.%
[Completed]: Capture 1 has been addedThe Apply Process keeps its position in the Target Database, so the Target is prepared too (see Prepare Target Database):
repcli>prepare database=target dbtype=mssql server=db-tgt.example.com port=1433 user=repuser password=Passw0rd123 dbname=testDB
[Completed]: Database [db-tgt.example.com:1433,testDB] has been prepared.The Apply Process reads the trail files of the Capture Process and applies the changes to the Target Database. capturename=rep1 connects it to the Capture Process rep1 (see Prepare Apply Process):
repcli>prepare process=apply id=1 dbtype=mssql capturename=rep1 server=db-tgt.example.com port=1433 user=repuser password=Passw0rd123 dbname=testDB
[Completed]: Apply 1 has been addedStart the Capture Process first and then the Apply Process. The commands return at once and the processes start in the background (see Run any Capture or Apply Processes):
repcli>run process=capture id=1
[In Process]: Command [RUN] has been sent. Use [status] command to monitor the Capture 1 process
repcli>run process=apply id=1
[In Process]: Command [RUN] has been sent. Use [status] command to monitor the Apply 1 processTo start a process when it is created, and every time the Repstance server starts, add autostart=1 to the prepare command of the process.
The command status shows the processes (see Status of any Capture or Apply Processes):
repcli>status
Capture Process 1, Name: rep1, DB: testDB, Server: db-src.example.com
RUN (In Process), Waiting for Transactions
Last Source DB Change : 2026/10/20 19:19:00.513 UTC (0x0000008D000091E20007)
Last Captured DB Change : 2026/10/20 19:19:00.513 UTC (0x0000008D000091E20007)
Total since 2026/10/20 15:34:00.253 UTC (0x0000008D00007B6B0007):
Processing the Transactions : 00:00:01.303
Waiting for Transactions : 03:44:25.112
Average Speed (ops) : 345.323
Transactions : 225 (DDL: 0, Delete: 225, Insert: 225, Update: 0)
Apply Process 1, Transactions Provider (Capture): rep1, DB: testDB, Server: db-tgt.example.com
RUN (In Process), Waiting for Transactions
Last Source DB Change : 2026/10/20 19:19:00.513 UTC (0x0000008D000091E20007)
Last Applied DB Change : 2026/10/20 19:19:00.513 UTC (0x0000008D000091E20007)
Lag : 00:00:00.000
Total since 2026/10/20 16:07:29.970 UTC (0x0000008D00007E380007):
Processing the Transactions : 00:00:03.344
Waiting for Transactions : 03:12:01.597
Average Speed (ops) : 116.011
Transactions : 194 (DDL: 0, Delete: 194, Insert: 194, Update: 0)RUN (In Process), Waiting for Transactions means that the process is running and has nothing to process at the moment. The Apply Process shows the last change of the Source Database that it knows, the last change that it has applied and the lag between them. The lines below Total since count what the process has done since it was started.
Change a row in a table of the Source Database and run status again: the numbers of the transactions grow. The command report shows the numbers for every table (see Report Process). DATA COMPARISON compares the data of the two databases. It matches the rows by the primary key or the unique index of a table, and it skips a table that has none, unless the key columns are named (see Requirements and Limits). The replication itself does not need a key.
Prev page:
CONFIGURE REPLICATION WITH REPSTANCENext page:
Initial Data Migration