OPTIONS

db.cloneDatabase()

On this page

Definition

db.cloneDatabase("hostname")

Copies a remote database to the current database. The command assumes that the remote database has the same name as the current database.

Parameter Type Description
hostname string The hostname of the database to copy.

This method provides a wrapper around the MongoDB database commandclone.” The copydb database command provides related functionality.

Example

To clone a database named importdb on a host named hostname, issue the following:

use importdb
db.cloneDatabase("hostname")

New databases are implicitly created, so the current host does not need to have a database named importdb for this command to succeed.