Skip to main content

Backup MongoDB Docker container via Bash script

 

datetmp=$(date '+%Y%m%d')
dateprod=${datetmp:2}
docker exec <dockercontainername> /bin/sh -c "mongodump --host="localhost:27017" --port=27017 -o '/data/backups/${dateprod} backup'"