How to migrate a collection from one system to another by using specific conditions like date

I tried to migrate my collection in a database from one system to another but i was not able to get a solution.


Need some clarity. You’re trying to get a copy of your collection:

  1. from one machine to another machine?
  2. use the same database name?
  3. use the same collection name?
  4. the collection does or does not exist on the target db?
  5. use a filter criteria to include specific documents?
  6. preserve the indexes and other collection attributes?

Correct the above where appropriate.

1.I want to transfer a Collection from one computer to another
2.The transformation process must be based on certain criteria like when we mention about the dates the documents lesser than the mentioned date should be migrated to another system.
3.we should use the same database and collection name
4.If the saved collection or database name does’nt exist we have to create a collection or database with the same name.
5.After migrating the message should be popped up like successfully migrated

Sounds like you don’t need this?

yah it is not neccessary to preserve the indexes and other collection attributes

Ok. You have a two options that are to be used in pairs:

  1. mongoexport and mongoimport
  2. mongodump and mongorestore

The documentation to these tools can be found here.

thank you so much for your valuable help
by using this mongoexport and mongoimport or mongodump and restore can we do automatically transfer documents from one system to the other

You mean scheduling? None of those tools have scheduling capabilities but you can either write a script to run those commands and schedule it to run on your server, or use MongoDB Ops Manager if you have the Enterprise edition of MongoDB.

Maybe one of the staff at MongoDB can tell you more about Ops Manager if they get to see your thread.

oh… thank you very much,I will try to work on it…

:slightly_smiling_face: :+1:

1 Like

Sir,I have an another doubt how can I effectively design a MongoDB schema for a Relational Database.


Please check the following thread: