- Reference >
- Database Commands >
- Administration Commands >
- clone
clone¶
-
clone¶ The
clonecommand clones a database from a remote MongoDB instance to the current host.clonecopies the database on the remote instance with the same name as the current database. The command takes the following form:Replace
db1.example.net:27017above with the resolvable hostname for the MongoDB instance you wish to copy from. Note the following behaviors:clonecan run against a slave or a non-primary member of a replica set.clonedoes 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.- You must run
cloneon the destination server. - The destination server is not locked for the duration of the
cloneoperation. This means thatclonewill occasionally yield to allow other operations to complete.
See
copydbfor similar functionality with greater flexibility.Warning
This command obtains an intermittent write lock on the destination server, which can block other operations until it completes.