Using copydb
Run the copydb under admin database with from,to, host parameters
>use admin
switched to db admin
> db.runCommand({ copydb: 1, fromdb: “test”, todb: “new_test”, fromhost: “localhost” })
Using copyDatabase method
The db.copyDatabase() method is used to copy a database.
>db.copyDatabase(“source_test”,”TargetTest”,”LocalHost”)