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.

Was this page helpful?

Yes No

Thank you for your feedback!

We're sorry! You can Report a Problem to help us improve this page.