-
Notifications
You must be signed in to change notification settings - Fork 4
Mongodb backup instruction
Arooran Thanabalasingam edited this page Jan 3, 2022
·
2 revisions
docker exec -i <CONTAINER> mongodump --db <DB> --gzip --archive > dump_$(date '+%d-%m-%Y_%H-%M-%S').gz
docker exec -i <CONTAINER> mongorestore --archive --gzip < dump.gz
- if mongodb runs inside a network, use the same network
- use mongodb container name as hostname
- with flag
--rm
, the container is destroyed after command is completed
docker run -i --network <NET> --rm mongo:4.4 mongodump --db <DB> --host <CONTAINER>:27017 --archive --gzip > dump_$(date '+%d-%m-%Y_%H-%M-%S').gz
- using URI schema
docker run -i --rm mongo:4.4 mongodump --uri "mongodb+srv://foo:[email protected]/db-name" --archive --gzip > dump_$(date '+%d-%m-%Y_%H-%M-%S').gz
docker run -i --network <NET> --rm mongo:4.4 mongorestore --host <CONTAINER>:27017 --archive --gzip < dump.gz
scp username@b:/path/origin/file /path/to/destination
based on