Mongodb Docker Backup

There are a few ways to back up data in mongo. For now I just want to use mongodump. I decided to create a shell script with something similar to:

docker exec mydatabase mongodump -o /data/db/backup -u root -p password -d mydatabase --authenticationDatabase admin --host localhost:27017 --gzip

Then cmod +x the file, and then open crontab crontab -e and add the following for daily backups (five past midnight)

5 0 * * * /path/backup.sh

Nice.

References