copyDatabase() verifiably creates the goal databases if it doesn’t exist on the off chance that you don’t determine the hostname contention.
Syntax:
db.copyDatabase(fromdb, todb, fromhost, username, password, mechanism)
Example:
db.copyDatabase("FOSSTECHNIX","FOSSTECHNIX_COPY");
Here we have covered MongoDB Copy Database.