Backup mongodb from a docker container to host
One of the recommended backup strategies of a mongodb database is through its tool called
As I do it on pomodoro.cc, we will use it to dump the current consistent state of the database with all its collections and move it to the host machine for persistence.
Let's say you have a docker container running a mongodb database with a volume on the host.
You can create a dump of the current state of the database with
docker run --rm -it --link DOCKER_CONTAINER_NAME:mongo_alias -v /backup:/backup mongo mongodump --host mongo_alias --out /backup/
Updated as suggested by sokrat in the comments
Share on Twitter