Skip to content

Instantly share code, notes, and snippets.

@bashkirtsevich
Created April 15, 2017 11:00
Show Gist options
  • Save bashkirtsevich/6f93b5a3092e37a43d4ea82501ce237a to your computer and use it in GitHub Desktop.
Save bashkirtsevich/6f93b5a3092e37a43d4ea82501ce237a to your computer and use it in GitHub Desktop.
MongoDB export full database

For lazy people like me, i use mongodump it's faster:

mongodump -d <database_name> -o <directory_backup>

And to "restore/import" that, i used (from directory_backup/dump/):

mongorestore -d <database_name> <directory_backup>

With this solution, you don't need to each all collections and export one by one. Just specify the database. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment