How to Backup and Restore MongoDB Database Quickly
Here is a quick command to get a backup and restore a Mongo DB.
--- To Backup ---
mongodump --db your-database-name — gzip — archive=your-database-name.archive
--- To Restore ---
mongorestore —-db your-database-name — gzip — archive=your-database-name.archive
Note:
- Your mongo db bin folder should be added on to PATH variable
- gzip argument will zip the file (when restores, gzip command will flag that the backup is zipped)
- Sometimes restoring wouldn’t work if the backing up server and restoring server has different versions of Mongo DB