One of the recommended backup strategies of a mongodb database is through its tool called mongodump
.
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 mongodump
.
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