This version of the manual is no longer supported.


db.copyDatabase(origin, destination, hostname)
  • origin (database) – Specifies the name of the database on the origin system.
  • destination (database) – Specifies the name of the database that you wish to copy the origin database into.
  • hostname (origin) – Indicate the hostname of the origin database host. Omit the hostname to copy from one name to another on the same server.

Use this function to copy a specific database, named origin running on the system accessible via hostname into the local database named destination. The command creates destination databases implicitly when they do not exist. If you omit the hostname, MongoDB will copy data from one database into another on the same instance.

This function provides a wrapper around the MongoDB database commandcopydb.” The clone database command provides related functionality.


Given a database named records that you want to copy into a database named archive_records, you could use the following invocation of db.copyDatabase():

db.copyDatabase('records', 'archive_records')