Backup MongoDB using mongodump

Backup a Whole Database

mongodump --db mydb
sudo mongodump --db mydb --out /var/backups/mongo

Backup a Single Collection

mongodump -d mydb -o /var/backups/mongo --collection users

Restore a Whole Database

sudo mongorestore --db mydb /var/backups/mongo/mydb

Restore a whole collection

mongorestore -d mydb -c users mydb/users.bson

Taking Regular Backups Using Mongodump/Mongorestore

sudo crontab -e

backup every day at 4:30 AM

30 4 * * * mongodump --db mydb

Archive output

mongodump --db monitoring --archive=monitoring_20190604.archive

Gzip output

mongodump --db monitoring --archive=monitoring_20190604.archive.gz --gzip

References
https://severalnines.com/blog/review-mongodb-backup-options
https://docs.mongodb.com/manual/reference/program/mongodump/