> This page location: /docs.md > /docs/tools-and-connectors.md > /docs/mongosync.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# About `mongosync`

MongoDB `mongosync` binaries are not supported or tested for use with non-genuine MongoDB deployments. While the tools may work on these deployments, compatibility is not guaranteed.

The [mongosync](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-binary.md#std-label-c2c-mongosync) binary is the primary process used in Mongosync. `mongosync` migrates data from a source cluster to a destination cluster.

`mongosync` replicates data and writes from one cluster to another until the sync is [finalized](https://www.mongodb.com/docs/mongosync/current/about-mongosync.md#std-label-c2c-about-finalizing). You can use this tool to perform one-time data migrations between MongoDB clusters with minimal downtime.

For more information about `mongosync` and destination cluster behavior during execution, see [Mid-sync Considerations.](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-behavior.md#std-label-mongosync-considerations)

**Important:**

Until you've called [`commit`](https://www.mongodb.com/docs/mongosync/current/reference/api/commit.md#std-label-c2c-api-commit) on `mongosync` and `canWrite` successfully returns `true`, the migrated collections on the destination cluster cannot be used to accept application read or write traffic. Do not use `mongosync` to maintain secondary clusters for Disaster Recovery, Analytics, or other similar use cases.

`mongosync` keeps track of its current actions through [states](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-states.md#std-label-c2c-states). `mongosync` enters different states depending on the requests it receives. The current `mongosync` state determines which API operations you can run.

**Note:**

Most state transitions happen as the result of an API call. The exceptions are:

- The transition from `COMMITTING` to `COMMITTED`. For more information, see [Finalizing Sync.](https://www.mongodb.com/docs/mongosync/current/about-mongosync.md#std-label-c2c-about-finalizing)

- The transition from `REVERSING` to `RUNNING`. For more information, see [Reversing Sync.](https://www.mongodb.com/docs/mongosync/current/about-mongosync.md#std-label-c2c-about-reversing)

To view the current state of `mongosync`, use the [/progress](https://www.mongodb.com/docs/mongosync/current/reference/api/progress.md#std-label-c2c-api-progress) endpoint.

The following diagram illustrates the relationship between `mongosync` states and API operations:

![Diagram of relationship between \`\`mongosync\`\` states and API operations](/images/mongosync.drawio.bakedsvg.svg)

The [Frequently Asked Questions (FAQ)](https://www.mongodb.com/docs/mongosync/current/faq.md#std-label-c2c-faq) page addresses questions users have asked about `mongosync`.

## Details

### Connect Source and Destination Clusters

You must create an initial connection to the source and destination clusters before `mongosync` can start to sync data. For connection instructions, see the documentation for your cluster architecture:

- [Atlas to Atlas](https://www.mongodb.com/docs/mongosync/current/connecting/atlas-to-atlas.md#std-label-c2c-conn-atlas2atlas)

- [Self-Managed to Self-Managed](https://www.mongodb.com/docs/mongosync/current/connecting/onprem-to-onprem.md#std-label-c2c-conn-oprem2onprem)

- [Self-Managed to Atlas](https://www.mongodb.com/docs/mongosync/current/connecting/onprem-to-atlas.md#std-label-c2c-conn-onprem2atlas)

When `mongosync` connects to the source and destination clusters, the synchronization process enters the [IDLE](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-states.md#std-label-c2c-state-idle) state.

### Start Sync

To start the synchronization process, call the [start](https://www.mongodb.com/docs/mongosync/current/reference/api/start.md#std-label-c2c-api-start) endpoint.

The `start` endpoint begins the `RUNNING` state, which is when `mongosync` syncs data from the source cluster to the destination cluster. If you make subsequent writes to the source cluster, `mongosync` applies the operations to the destination cluster.

For every source collection that syncs, `mongosync` creates a corresponding collection on the destination.

`mongosync` temporarily alters some of the replicated collection characteristics in the destination cluster. It changes these destination cluster characteristics back to the source cluster characteristics during the `COMMIT` state. For more information, see [Collection Characteristic Changes.](https://www.mongodb.com/docs/mongosync/current/reference/api/commit.md#std-label-c2c-collection-changes)

The `RUNNING` state includes two phases:

- [Collection copy](https://www.mongodb.com/docs/mongosync/current/about-mongosync.md#std-label-c2c-collection-copy)

- [Change event application](https://www.mongodb.com/docs/mongosync/current/about-mongosync.md#std-label-c2c-cea)

#### Collection Copy

During the collection copy phase, `mongosync` executes the initial data transfer from the source cluster to the destination cluster. `mongosync` performs this data transfer by splitting the source collections into partitions and copying the partitions to their corresponding destination collections.

For migrations with small destination clusters, the collection copy phase can exhaust the destination cluster's CPU and/or memory. For migrations with a total collection size of 64GB or less, to destination clusters with 4 or less CPUs/vCPUs, the collection copy phase issues fewer concurrent writes to the destination cluster. Migrations larger than 64GB continue to use the default write concurrency.

To disable this feature, specify an explicit [load level](https://www.mongodb.com/docs/mongosync/current/reference/configuration.md#std-label-mongosync-load-level) when you start or restart `mongosync`.

#### Change Event Application

The change event application (CEA) phase starts after the collection copy phase ends.

During the CEA phase, `mongosync` makes ongoing changes to the destination cluster as you write to the source cluster.

To make ongoing updates to the destination cluster, `mongosync` opens a [change stream](https://www.mongodb.com/docs/manual/changeStreams.md#std-label-changeStreams) on the source cluster and applies the [change events](https://www.mongodb.com/docs/manual/reference/change-events.md#std-label-change-events) it receives to the destination cluster.

When the CEA phase begins, `mongosync` applies the change events that are received during the collection copy phase before processing the events that are received during the CEA phase.

### Pause Sync

To pause the sync process and enter the [PAUSED](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-states.md#std-label-c2c-state-paused) state, call the [pause](https://www.mongodb.com/docs/mongosync/current/reference/api/pause.md#std-label-c2c-api-pause) endpoint.

To resume a paused sync process and return `mongosync` to the `RUNNING` state, call the [resume](https://www.mongodb.com/docs/mongosync/current/reference/api/resume.md#std-label-c2c-api-resume) endpoint.

### Finalize Sync

To finalize the sync between the source and destination clusters, call the [commit](https://www.mongodb.com/docs/mongosync/current/reference/api/commit.md#std-label-c2c-api-commit) endpoint.

The `commit` endpoint starts the [COMMITTING](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-states.md#std-label-c2c-state-committing) state, which is when `mongosync` stops migrating data between the source and destination clusters.

When the `COMMITTING` state begins, `mongosync` retrieves the commit timestamp, which is the time of the most recent operation on the source cluster.

If there are no errors, `mongosync` sends a success message and exits CEA by processing events up until the commit timestamp. `mongosync` also restores collection characteristics that `mongosync` temporarily alters during synchronization.

When the above process is completed, `mongosync` enters the [COMMITTED](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-states.md#std-label-c2c-state-committed) state. The `COMMITTED` state indicates that the [cutover process](https://www.mongodb.com/docs/mongosync/current/reference/cutover-process.md#std-label-c2c-cutover-process) is finished.

### Reverse Sync

To reverse the direction of a committed sync operation, call the [reverse](https://www.mongodb.com/docs/mongosync/current/reference/api/reverse.md#std-label-c2c-api-reverse) endpoint.

The `reverse` endpoint starts the [REVERSING](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-states.md#std-label-c2c-state-reversing) state. `mongosync` swaps the source and destination clusters and resumes applying change events.

If the reverse sync is successful, `mongosync` enters the `RUNNING` state. The synchronization continues in the reverse direction from the original sync job.

## Learn More

To learn more about `mongosync`, see:

- [`mongosync` Binary](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-binary.md#std-label-c2c-mongosync)

- [mongosync Behavior](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-behavior.md#std-label-c2c-mongosync-behavior)

- [mongosync Migration Limitations](https://www.mongodb.com/docs/mongosync/current/reference/limitations.md#std-label-c2c-limitations)
