Hi Lee,
Is there a preferred method to copy collections to another database? For example when we move from DEV to QA or QA to PRODUCTION.
PRODUCTION would be 3 member replicaset, others are single instances.
You can use the cloneCollection
database command to copy a collection from one server to another. For example, if you want to copy a collection called examples
from the server dev-server
in database test
:
db.runCommand({cloneCollection:"test.examples",from:"dev-server:27017"})
Please note that there are some caveats with the cloneCollection
command:
mongos
does not support the commandThe cloneCollection
command will also copy the indexes of the source collection.
Generally it works OK, but we have noticed sometimes during/after copying to PRODUCTION the replicaset members could hit 400% CPU and may cause degraded performance.
This may be caused by the Secondary members building indexes during the import process.
Best regards,
Kevin