How to verify the integrity of the files that result from a mongodump operation?
Asked Answered
P

2

16

From the research I have done, mongodump doesn't have a built-in check to verify the integrity of a mongodump operation; at least, nothing apparent to the user. I may be wrong. If I am, please inform me. Otherwise, I'm sure I'm not the only one who wishes to verify their mongodump operation copied the data without any corruption or loss. What are the various methods others have used to insure the integrity of their mongodump files? If the method for doing so is inherently different on a sharded cluster, please answer how to do so on a single MongoDB instance and one that is sharded.

Pledge answered 22/4, 2014 at 15:18 Comment(2)
I know that's quite old, but I'd love to see an answer here. Any luck finding one?Kurtis
Nope, no luck finding an answer.Pledge
K
0

I have use db.collection.validate({full:true}) in the past which will validate the contents of the collection in question. Granted this is on a collection by collection basis to the best of my knowledge and is probably not to feasible for full DB restores. Since i will typically restore a collection or two only to a different env, i will do the .validate() before on the source and then after on the destination and compare the outputs.

Kraal answered 1/5, 2017 at 21:33 Comment(0)
J
0

Easy and simple way is to check using the DB stats command which gives you more details about the count of each collections,views,objects and indexes. With this below command you can cross check source and destination databases whether the data is consistent post restoration.

use database

db.stats()

Note: Don't compare the dataSize or storageSize because the source db might have huge size since they have fragmented data.

Jabe answered 17/2, 2022 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.