Docs Menu
Docs Home
/
MongoDB Cluster-to-Cluster Sync
/ /

Handle Pre-Existing Data on the Destination

On this page

  • Syntax
  • Command Option
  • Behavior
  • Steps
  • 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.

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.

To set a "destinationDataHandling" option string:

curl <host>:<port>/api/v1/start -XPOST \
--data '
{
<options>,
"destinationDataHandling": <string>
} '

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.

"ignorePreExistingNamespaces" is not compatible with reverse.

If you omit a "destinationDataHandling" string, and the destination cluster has user data, mongosync returns an error. Otherwise, mongosync continues the sync operation.

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.

1

The following example connects a source cluster (cluster0) with a destination cluster (cluster1):

mongosync \
--cluster0 "mongodb://localhost:27000" \
--cluster1 "mongodb://localhost:35000"
2

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.

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.

Back

Document Filtering