- Reference >
mongoShell Methods >- Database Methods >
- db.cloneDatabase()
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 hostnamestring The hostname of the database to copy. This method provides a wrapper around the MongoDB database command “
clone.” Thecopydbdatabase command provides related functionality.
Example¶
To clone a database named importdb on a host named hostname,
issue the following:
New databases are implicitly created, so the current host does not
need to have a database named importdb for this command to
succeed.