Skip to content

edmallia/mongodb-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongodb-scripts

Collection of mongodb scripts

Migration Verification Scripts

These scripts require at least Mongo Shell 3.6. The scripts will not work on Mongo Shell of a lower version. They have been tried against source MongoDB Server versions 3.0, 3.2, 3.4, 3.6.

randomVerifier.js

The steps performed in the verification script are outlined below

  1. For each collection in the whitelisted databases (note, supply null as whitelist to process all databases)
    1. Select a random set of _id from the given collection. The selection is run on the source collection and runs against the _id index. The selection is configured by supplying,
      • Total sample size
      • Number of sections to partition the collection space
      • The script will pick up a proportional number of documents from each partition.
      • If the requested sample size is larger than the collection size, then all the collection will be considered.
    2. Using the chosen _id’s, the script will run the following process on both the source and the destination databases,
      • Find the required documents.
      • Order all the keys in the document in alphabetical order (to counteract the different behavior between MongoDB 3.0 and MongoDB 4.4).
      • Output the result into a temporary output collection.
    3. Generate the dbHash for the output collections.
    4. Compare dbHash’es and report.

countVerifier.js

The steps performed in the verification script are outlined below

  1. For each collection in the whitelisted databases (note, supply null as whitelist to process all databases)
    1. Count the number of documents in the given collection on the source database.
    2. Count the number of documents in the given collection on the destination database.
    3. Compare counts and report.

metadataVerifier.js

The steps performed in the verification script are outlined below

  1. For each collection in the whitelisted databases (note, supply null as whitelist to process all databases)
    1. Extract the getCollectionInfos(..) and getIndexes() output for the given collection on the source database.
    2. Extract the getCollectionInfos(..) and getIndexes() output for the given collection on the destination database.
    3. Compare outputs as a JSON string and report.

About

Collection of mongodb scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published