MongoDB Copy Database
Use
Syntax:
db.copyDatabase(fromdb, todb, fromhost, username, password, mechanism)
Examples:
Copy Database on Same Instance
You can create a duplicate database in same instance by using copyDatabase() function.
db.copyDatabase("olddb","newdb")
Output:
{ "ok" : 1 }
Also you can use above option to rename database in MongoDB. But you must have enough space to create a copy of an existing database with a different name. After that, you can remove the old database to release space.
Copy Database from Remote Instance
You can also use
db.copyDatabase("remote_dbname","local_dbname","10.8.0.2","username","password")
The above command will show a large output on your screen as per available documents in the database.