Verify Data Transfer
On this page
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Starting in 1.9, When the The verifier doesn't check every aspect of a migration:
| |||||||||||||
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,
This method only verifies a successful sync when run against clusters with insert-only workloads. | |||||||||||||
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,
While hash comparison ensures that the destination
cluster has received all changes from the source, the
Hash comparison is not possible with sharded clusters. It also does not work with standalone servers and replica sets that use MongoDB 4.4 or earlier releases, since the document field order can vary. | |||||||||||||
Document Comparison | You can verify sync by comparing documents on the source and destination clusters. Write a script that queries collections on the source cluster and then checks that the correct documents, indexes, collections, metadata, and views exist with the same values on the destination cluster. Before you can verify data transfer with this method,
| ||||||||||||
Index Comparison | To verify the transfer of indexes, run the
| ||||||||||||
Metadata Comparison | To verify the transfer of metadata, run the
| ||||||||||||
Shard Key Comparison | To verify the transfer of shard keys to a synced collection, run a query on the For example, for a collection named
| ||||||||||||
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. Migration Verifier is an experimental and unsupported tool. |
The specific method you use to verify your data depends on your application workload and the complexity of the data.