Verify Data Transfer
On this page
When mongosync has fully committed, verify the successful transfer of your data before you switch your application to using the destination cluster. You can verify your data transfer using document counts, hash comparison, document comparison, or the Migration Verifier.
Use Cases
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 methods:
The specific method you use to verify your data depends on your application workload and the complexity of the data.
Tasks
Document 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.
This method only verifies a successful sync when run against clusters with insert-only workloads.
For more information, see Verify with Document Counts.
Hash Comparison
You can verify sync by comparing MD5 hashes of collections synced from the source cluster to the destination cluster.
While hash comparison ensures that the destination cluster has received all
changes from the source, the dbHash
command locks the cluster,
preventing additional writes until it completes.
Note
Hash comparison is not possible with sharded clusters. It also does not work for standalone servers and replica sets that use MongoDB 4.4 or earlier releases, since the document field order can vary.
For more information, see Verify with Hash Comparison.
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 document exists with the same values on the destination cluster.
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.
Important
Migration Verifier is an experimental and unsupported tool.
For installation instructions, see GitHub.
Unlike other verification methods, Migration Verifier can run concurrent
with mongosync
, checking documents on the destination cluster as they
sync.
For more information, see Verify with Migration Verifier.
Learn More
For more information, see: