Is there a way to Clone a MongoDB database and its data with MongoDB Compass to my local server? I do not want to corrupt the dev environment by accident so I want to test things out locally, but I can't find a solution for that on MongoDB Compass.
MongoDB Compass has a great documentation explaining how you can import/export one collection at the time for both JSON and CSV files.
I think that there is no better answer than the link to the documentation: https://docs.mongodb.com/compass/current/import-export#import-data-into-a-collection
To clone an existing database to a new one, use the mongodump and mongorestore commands.
To dump DB:
mongodump -d <database_name> -o <directory_backup>
To clone DB:
mongorestore -d <new_database_name> <directory_backup>/<database_name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With