I have two clusters of mongo database, each having three machines. Say Cluster1 and Cluster2. To reduce cost I have to terminate Cluster2. So I took mongodump of one database from the primary machine of Cluster2 which is 8.5 GB. I copied that dump folder to the primary machine of Cluster1 and run there mongorestore command but when I run show dbs command on Cluster1 it shows the size as 4.7GB. So my question is, did I make any mistake or mongorestore does not restore indexes or any other reason?
-  does anybody have answer for it? It is quite urgent for me.innervoice– innervoice2019-12-09 06:18:41 +00:00Commented Dec 9, 2019 at 6:18
1 Answer
It is possible that your storage size (which show dbs indicates) varies on restore, especially if the original deployment had a lot of space available for reuse (for example, due to document deletion). A mongodump backs up data and index definitions, and the mongorestore process will rebuild the data files and indexes for restored collections.
For a better comparison of your original and restored deployments you should review the db.stats() output.
Assuming there weren't any issues with the backup & restore process, both deployments should have a similar number of databases, collections, indexes, and objects. If your original deployment was being actively written to while (or after) the mongodump was taken, the outcome may differ slightly.
For example, to output stats for all databases via the mongo shell:
db.adminCommand('listDatabases').databases.forEach(function(d) { printjson(db.getSiblingDB(d.name).stats()); }) -  Thanks Stennie... perfect solution.innervoice– innervoice2019-12-22 08:41:01 +00:00Commented Dec 22, 2019 at 8:41