How to backup MongoDB

Posted in #mongodb 5.30.2015

Backing up mongodb database is fairly simple. If you have a mongodb user associated with the database, you can use the following command to make a backup.

/path/to/mongodump -d your_db --username db_user -p -o /your/backup/path/mongodb/your_db-mongodump

To backup MongoDB database using the gzip option:

mongodump --db your_db_name --gzip -o /your/backup/path/

To Restore the database when using gzip option:

mongorestore --gzip --db your_db_name /your/backup/path