Studio 3T’s convenient built-in copy and paste features allow you to copy or duplicate a MongoDB collection to another database in just a few clicks.
Copy MongoDB collection
Select the source collection you want to copy and right-click it in the Connection Tree.
In our case, this is collection test.people
on localhost.
Choose Copy Collection.
Paste MongoDB collection
Select your target MongoDB database (or collection) that you want to copy your source collection to.
In our example, that is database “test” on server “ADX”.
Right-click your target and choose Paste Collection.
Configure copy & paste
In the Paste Collection dialog, you can choose how the copy operation should treat (existing) document _ids.
If you paste a collection into a target database that already contains a collection with the same name, the source collection will be inserted with the prefix “Copy_of_”.
To finish, click Paste Collection. This will copy your source collection to your target.
And just like that, your MongoDB collection is copied to another database and/or server.
Great. I like it.
Hey,
Can I add my DB that locate on AWS server?
When I’m trying to add DB, it asks me for name and I have no idea what my data base’s name
Regards,
David
Hi David,
Thanks for reaching out to us! If you’re able to connect to AWS with Studio 3T, the connection tree should should display your database name. If this doesn’t solve your question, please reach out to us at [email protected].
Regards,
Dakota
Hi, this is a lovely feature thanks
What is the equivalent from a scripted point of view? I have a migration and I would rather have all the moving of collections done with a script. One can extract and import but then the indexes get lost. Please advise.
Hello James!
Thanks for this question. At the moment, you can try running db.copyDatabase() in IntelliShell to see if that solves your problem – https://docs.mongodb.com/manual/reference/method/db.copyDatabase/. If that doesn’t work with IntelliShell, please reach out to us at [email protected] with more details about your migration and we’ll do our best to solve your query!
Cheers,
Dakota