MongoDB in Docker - backup database on container shutdown -


i'm trying setup docker-compose node , mongodb. in combination official mongo container i'm using dedicated container (mongodb-backup) continuous backups of database , initial restore @ startup.

my problem how trigger backup in case of graceful shutdown docker-compose stop.
therefore it's necessary shut down node container @ first guarantee no process writing database. backup database , shutdown mongodb , mongodb-backup conatainers.

this repository contains docker-compose setup of mongodb , mongodb-backup.

does have idea how implement this?

you write small maintenance script case. instead of doing raw docker-compose stop, run script instead. let's call maintenance.sh:

#!/bin/sh docker-compose stop app docker-compose stop mongo-backup # ensure 1 active docker-compose run --rm -e init_backup=1 # backup manually docker-compose stop mongo # stop database 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -