I have a collection with more than 1 TB size and wanted to move it another MongoDB cluster

PS: Both clusters are sharded over 5 shards and they are on-prem infra.

marked as duplicate by hot2use, mustaccio, Colin 't Hart, Marco, Randi Vertongen Mar 21 at 15:25

This question was marked as an exact duplicate of an existing question.


As per MongoDB documentation here through the db.cloneCollection(from, collection, query) it's Copies data directly between MongoDB instances.

use users
db.cloneCollection('mongodb.example.net:27017', 'profiles',
                    { 'active' : true } )

This operation copies the profiles collection from the users database on the server at mongodb.example.net into the users database on the local server. The operation only copies documents that satisfy the query { 'active' : true }.

For further your ref here , here , here and here

  • Thanks, but mongos does not support db.cloneCollection() and db.copyDatabase(), I am curious how this will work for a shared cluster? – andy_l Mar 20 at 9:57
  • Yes, in documents there is mention – Md Haidar Ali Khan Mar 20 at 9:58
  • docs.mongodb.com/manual/reference/method/db.copyDatabase Sharded Clusters Do not use db.copyDatabase() from a mongos instance. Do not use db.copyDatabase() to copy databases that contain sharded collections. – andy_l Mar 20 at 10:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.