On this page

  • clone
    • The clone command clones a database from a mongod instance to the current mongod instance.

The command takes the following form:

{ clone: <copyfromhost:port>, writeConcern: <document>, bypassDocumentValidation: <boolean> }

cloneCollection has the following fields:

hostnamestringThe hostname of the database to copy.
writeConcerndocumentOptional. A document that expresses the write concern for the operation. Omit to use the default write concern.
bypassDocumentValidationbooleanOptional. Enables clone to bypass document validation during the operation. This lets you insert documents that do not meet the validation requirements.
New in version 3.2.

To use the clone command, run the command on the destination server , specifying the source to copy from. The database where you run the command determines which database to copy from the source.

The mongo shell provides the method db.cloneDatabase() as a wrapper for the clone command.



The clone command does not snapshot the database. If any clients update the database you’re copying at any point during the clone operation, the resulting database may be inconsistent.


The destination database will be locked periodically during the clone operation. In other words, clone will occasionally yield to allow other operations on the database to complete.


You cannot copy data between a mongod instance with featureCompatibilityVersion (FCV) 3.6 and a MongoDB version 3.4 and earlier mongod instance.

For example:

Instance 1Instance 2
Version 3.6 mongod with FCV 3.6Version 3.6 mongod with FCV 3.6Can copy data.
Version 3.6 mongod with FCV 3.6Version 3.6 mongod with FCV 3.4Can copy data.
Version 3.6 mongod with FCV 3.6Version 3.4 mongod with FCV 3.4Cannot copy data. Instance 2 must be a MongoDB version 3.6
Version 3.6 mongod with FCV 3.4Version 3.4 mongod with FCV 3.4Can copy data.
Version 3.6 mongod with FCV 3.4Version 3.2 mongodCan copy data.

Operations that copy data include:

Replica Sets

The clone command can copy from a secondary member of a replica set.


The following operation copies the marketing database from "" to the mongod instance where you issue the db.runCommand().

use marketing
db.runCommand( { clone: "" })