Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Thanks for the awesome tutorial. MongoDB is little bit complicated for me but this tutorial made everything easy.
Thanks for the tutorial.
I wanted to point out one issue with it since it took me a while to figure out why my cron jobs weren’t running.
The cron line for the dump above is:
3 3 * * * mongodump --out /var/backups/mongobackups/`date +"%m-%d-%y"`
BUT the % character has special meaning to cron and will result in that job not running. If you watch the syslog when the job runs you’d see the command logged as:
mongodump --out /var/backups/mongobackups/`date +"
The % chars need to be escaped (\%) like:
3 3 * * * mongodump --out /var/backups/mongobackups/`date +"\%m-\%d-\%y"`
and then the job should run properly.
I think deleting of old backups can by simplified by using delete flag:
3 1 * * * find /var/backups/mongobackups/ -mtime +7 -delete
hI
I tryied the mongodump command, as described above but i get this error message:
Failed: error getting collections for database ibyc_db: error running listCollections. Database: ibyc_db Err: not authorized on ibyc_db to execute command { listCollections: 1, cursor: {} }
could someone help please?
thx
Awesome tutorial, how would you go about setting up backups for a replication set? Do you set backup and cleanup cron jobs on each of the nodes (primary & secondary)?
Thank in advance for you input!
Since MongoDB 3.2 you can now archive and compress with 2 new command line options: https://www.mongodb.com/blog/post/archiving-and-compression-in-mongodb-tools
So you can now use this:
3 3 * * * mongodump --archive=/var/backups/mongobackups/`date '+%FT%H-%M-%S-%Z'`.archive --gzip
I’m concerning about the data duplication between backup and restore times. Does mongodb have a mechanism to detect and de-duplicate data ?
For anyone having problems removing the old backups, replace the cronjob given in the tutorial with this:
To remove backups older than 7 days at 3:01 am every day (just before main backup cronjob):
1 3 * * * find /var/backups/mongobackups/* -maxdepth 0 -ctime +7 -exec rm -fr {} +
For anyone having problems with the backup-removal cronjob, try this instead, worked for me:
1 3 * * * find /var/backups/mongobackups/* -maxdepth 0 -ctime +7 -exec rm -fr {} +