DEV Community

Cover image for MongoDB Complete Backup And Restore Command With Atlas
Jastria Rahmat
Jastria Rahmat

Posted on

MongoDB Complete Backup And Restore Command With Atlas

This is tested using POSIX environment, especially linux mint. No guarantee will work with others. This technique is using mongodump and mongorestore commands.

Backup From Atlas

Using Atlas
go to specific folder and dump the db.

mongodump --uri="mongodb+srv://<USERNAME>:<PASSWORD>@<CLUSTER_NAME>.mongodb.net/<DB_NAME>
Enter fullscreen mode Exit fullscreen mode

it will create folder dump with collection name inside.

Restore To Atlas

within the same folder, run:

mongorestore --uri="mongodb+srv://<USERNAME>:<PASSWORD>@<CLUSTER_NAME>.mongodb.net/<TARGET_DB_NAME>" ./dump/<DB_FOLDER>/
Enter fullscreen mode Exit fullscreen mode

done.

Discussion (0)