First off let me say I am a newB when it comes to Mongo, so excuse my ignorance. With that being said:
Using db.copyDatabase()
to copy a remote database:
What impact does this have on the database being copied. Please note the the database being copied is currently being use by a live application.
Would db.copyDatabase()
lock the database?
What about performance, would it make the database run slower?
I don't really mind if while coping some new data is being written to the DB. The copy does not have to be exact per say, it just need to be as close as possible to the live DB. But I am really concern about performance issue, is it safe to do this on a live DB?
Best Answer
The docs for MongoDB discuss the behavior of copyDatabase in detail: http://docs.mongodb.org/manual/reference/method/db.copyDatabase/#behavior
Specifically, copyDatabase reads the data from the source DB the same way something like a backup or full collection query would read it - that means that it may impact the performance of that DB (for example, by bringing more data into RAM which may displace some other data) but the impact would be about the same as running
mongodump
on that DB.The docs do explicitly mention that the copied database does not get locked.
If you are running a replica set, you can copyDatabase from a secondary node