Created
March 11, 2023 08:57
-
-
Save bala-codes/b9a620e112f4f5322c94301b2d58daaf to your computer and use it in GitHub Desktop.
MongoDB Import and Export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get upgrade | |
sudo dpkg -l mongodb-database-tools | |
curl -o mongodb-database-tools-ubuntu2004-x86_64-100.2.1.deb https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.2.1.deb | |
sudo apt install ./mongodb-database-tools-ubuntu2004-x86_64-100.2.1.deb | |
mongodump --uri "mongodb+srv://<username>:<password>@client-dev-cluster0.qf5b6.mongodb.net/dbname" -o ./mongo-backup | |
mongorestore --uri "mongodb+srv://<username>:<password>@client-dev-cluster1.qf5b6.mongodb.net/dbname" ./mongo-backup/ | |
## If you want to exclude any collections | |
mongodump --uri "mongodb+srv://<username>:<password>@client-dev-cluster0.qf5b6.mongodb.net/dbname" -o ./mongo-backup --excludeCollection <collection_name> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment