Studio 3T’s built-in copy and paste collection feature is the fastest way to copy (or duplicate) an entire MongoDB collection to another database. The ability to copy collections is useful for migrating data, backing up data, setting up development or test environments, and creating subsets of data for security purposes.
If you’re looking to create subsets of data, check out our Export Wizard, where you can export a collection from MongoDB to another collection with the results from a find query or an aggregation query. With the Export Wizard, you can also mask sensitive data at field level if you’re concerned about data privacy.
Copy MongoDB collection
In the Connection Tree, find the source collection you want to copy and right-click it. You can copy all the collections in a database by selecting the Collections node and right-clicking it.
Select Copy Collection(s).
Paste MongoDB collection
In the Connection Tree, select the target MongoDB database where you want to copy your source collection(s) and right-click it.
Select Paste Collection(s).
Configure copy & paste
If you’re copying collections to existing target collections, in the Copy Collection dialog, you can choose to:
- Append to the existing collection and then choose how the copy operation treats the document _ids
- Replace the collection
- Create a collection with a new name
You also have the option to include or exclude the indexes on the collections and if it exists, copy the schema validator. To learn more about how MongoDB applies schema validation, see the MongoDB documentation.
This article was originally published by Thomas Zahn and has since been updated.