Copying Databases
Another common task with databases is copying them. Copying a database creates a duplicate of the database that is exactly the same except for the name. There are several reasons you might want to copy a database—for example, to have a backup while you perform heavy changes or as an archive.
To create a copy of a database, you switch to that database and then use copyDatabase(origin, destination, [hostname]) to create a copy. The origin parameter is a string that specifies the name of the database to copy. The destination parameter specifies the name of the database to create on this MongoDB server. The optional hostname parameter specifies a hostname of the origin database MongoDB server if you are copying a database from a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access