Docs Home → MongoDB Cluster-to-Cluster Sync
reverse

On this page
Description
Reverses the direction of a committed sync operation.
For example:
You have a
COMMITTED
sync operation.cluster0
is the source andcluster1
is the destination.After the sync operation is
COMMITTED
, new writes occur only on the destination cluster. The source cluster will not accept new writes.
In this scenario, you can use the reverse
endpoint to sync writes
from cluster1
to cluster0
.
Requirements
To use the reverse
endpoint:
You must have started your original sync operation with the
reversible
andenableUserWriteBlocking
options set totrue
.mongosync
must be in theCOMMITTED
state.Source and destination clusters must be MongoDB 6.0 or later.
Unique indexes on the original source cluster must be formatted properly. If an upgraded cluster has unique indexes that were created in MongoDB 4.2 or earlier, you must resync all of the nodes in the original source cluster before reversing.
Note
To use mongosync
in the reverse direction,
you must create a custom role that grants the
following ActionTypes:
The setUserWriteBlockMode
and bypassWriteBlockingMode
ActionTypes are available starting in MongoDB 6.0. To create the custom
roles, all clusters in a project must be on MongoDB 6.0 or higher.
Request
POST /api/v1/reverse
Request Body Parameters
This endpoint does not use HTTP request body parameters. However, you
must specify the --data
option with an empty object { }
.
Response
Field | Type | Description |
---|---|---|
success | boolean | When the request is successful, this value is true . |
error | string | If an error occurred, indicates the name of the error. This field
is omitted from the response when success is true . |
errorDescription | string | Detailed description of the error that occurred. This field is
omitted from the response when success is true . |
Example
The following example reverses the direction of a committed sync operation.
Request
curl localhost:27182/api/v1/reverse -XPOST --data '{ }'
Response
{"success":true}
Behavior
If the reverse
request is successful, mongosync
enters the
RUNNING
state. The synchronization continues in the reverse
direction from the original sync job. You do not need to restart the
entire sync process to copy the original data.
To view the mapping direction for the synchronization of the source and
destination clusters, use the progress
endpoint and check the directionMapping
object.