DEV Community

Cover image for MongoDB: How to export all collections? [Local/Remote]
YURII DE.
YURII DE.

Posted on • Updated on

MongoDB: How to export all collections? [Local/Remote]

Local

Dump

mongodump -d <database_name> -o <directory_backup>
Enter fullscreen mode Exit fullscreen mode

Restore

mongorestore -d <database_name> <directory_backup>
Enter fullscreen mode Exit fullscreen mode

Remote

Dump

mongodump --uri <uri_string> -o <directory_backup>
Enter fullscreen mode Exit fullscreen mode

Restore

mongorestore --uri <uri_string> <directory_backup>
Enter fullscreen mode Exit fullscreen mode

Note that I would recommend against using mongodump/mongorestore for big data storages. It is very slow and once you get past 10/20GB of data it can take hours to restore.

Top comments (0)