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

# Verify Data Transfer

Before you switch your application load from the source cluster to the destination cluster, you should verify that the migration was successful.

Starting in 1.9, `mongosync` provides an embedded verifier that can perform a series of verification checks on the source and destination cluster to confirm the sync was successful.

## Tasks

You should verify your data after every sync. This is important in cases where you plan to move your application load from the source to the destination cluster.

| Verification Method | Description |
| --- | --- |
| [Embedded Verifier](https://www.mongodb.com/docs/mongosync/current/reference/verification/embedded.md#std-label-c2c-embedded-verifier) | Starting in 1.9, `mongosync` includes an embedded verifier, which runs a series of verification checks on the source and destination clusters to confirm that the migration was successful. **This is the preferred verification method for deployments that meet the** [requirements.](https://www.mongodb.com/docs/mongosync/current/reference/limitations.md#std-label-c2c-verify-embedded-limitations) When the `mongosync` process starts, it prompts the user with a disclaimer about the embedded verifier. You must accept the disclaimer, or if you have already read and acknowledged it, start `mongosync` with the [`--acceptDisclaimer`](https://www.mongodb.com/docs/mongosync/current/reference/mongosync-binary.md#std-option-mongosync.--acceptDisclaimer) option to use the verifier. The verifier doesn't check every aspect of a migration: To verify sync on unsupported namespaces, use a different verification method.; To verify index sync, use the [Index Comparison](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-index-comparison) method.; To verify metdata sync, use the [Metadata Comparison](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-metadata-comparison) method. |
| [Document Counts](https://www.mongodb.com/docs/mongosync/current/reference/verification/count.md#std-label-c2c-verify-doc-counts) | The most basic method of verification is to compare the number of documents in each synced collection on the source cluster to the number on the destination cluster. Before you can verify data transfer with this method, `mongosync` must be in the `COMMITTED` state. This method only verifies a successful sync when run against clusters with insert-only workloads. |
| [Hash Comparison](https://www.mongodb.com/docs/mongosync/current/reference/verification/hash.md#std-label-c2c-verify-hash-comp) | You can verify sync by comparing MD5 hashes of collections synced from the source cluster to the destination cluster. Before you can verify data transfer with this method, `mongosync` must be in the `COMMITTED` state. While hash comparison ensures that the destination cluster has received all changes from the source, the [`dbHash`](https://www.mongodb.com/docs/manual/reference/command/dbHash.md#mongodb-dbcommand-dbcmd.dbHash) command locks the cluster, preventing additional writes until it completes. Hash comparison is **not** possible with sharded clusters. |
| [Migration Verifier](https://www.mongodb.com/docs/mongosync/current/reference/verification/verifier.md#std-label-c2c-migration-verifier) | Migration Verifier connects to the source and destination clusters and performs a series of verification checks, comparing documents, views, and indexes to confirm the sync was successful. |
| [Verifying Data with Custom Scripts](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-custom-manual-verification) | Different types of data require different methods of verification. You can can use custom or manual verification to verify [documents](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-document-comparison), [indexes](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-index-comparison), [metadata](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-metadata-comparison), and [shard keys.](https://www.mongodb.com/docs/mongosync/current/reference/verification/custom-manual.md#std-label-c2c-shardkey-comparison) |

The specific method you use to verify your data depends on your application workload and the complexity of the data.

## Learn More

- [`db.collection.countDocuments()`](https://www.mongodb.com/docs/manual/reference/method/db.collection.countDocuments.md#mongodb-method-db.collection.countDocuments)

- [`dbHash`](https://www.mongodb.com/docs/manual/reference/command/dbHash.md#mongodb-dbcommand-dbcmd.dbHash)
