Handle Pre-Existing Data on the Destination
On this page
Important
Cluster-to-Cluster Sync Beta Program
This feature is only available in mongosync
beta. To learn more,
see Cluster-to-Cluster Sync Beta Program.
Starting in mongosync
beta 1.8, use the destinationDataHandling
option in the start request to define what happens if the destination
cluster already has user data. Earlier mongosync
versions return an
error if the destination cluster has user data.
Syntax
To set a "destinationDataHandling"
option string:
curl <host>:<port>/api/v1/start -XPOST \ --data ' { <options>, "destinationDataHandling": <string> } '
Command Option
The following table shows the strings you can set for
"destinationDataHandling"
:
String | Description |
---|---|
"requireEmptyDestination" | mongosync requires databases on the destination
cluster that you want to replicate from the source
cluster are empty. "requireEmptyDestination" is the default. |
"ignorePreExistingNamespaces" | mongosync ignores existing databases on the destination
cluster. Ensure your destination namespaces are different from
those mongosync replicates from the source cluster. |
If you omit a "destinationDataHandling"
string, and the destination
cluster has user data, mongosync
returns an error. Otherwise,
mongosync
continues the sync operation.
Behavior
Verification
Destination Data Handling is not compatible with the Embedded Verifier. The /start command returns an error if you enable both the verifier and Destination Data Handling.
For more information, see Verify Data Transfer.
Steps
Set the destinationDataHandling string
The following example sets "destinationDataHandling"
to
"ignorePreExistingNamespaces"
:
curl localhost:27182/api/v1/start -XPOST \ --data ' { "source": "cluster0", "destination": "cluster1", "destinationDataHandling": "ignorePreExistingNamespaces" } '
The sync operation continues.
Learn More
Important
Cluster-to-Cluster Sync Beta Program
This feature is only available in mongosync
beta. To learn more,
see Cluster-to-Cluster Sync Beta Program.