/
MongoDB Backup and Restore
MongoDB Backup and Restore
During the work to move to using persistent storage for the mongodb docker containers we had to migrate the data stored within the docker container’s internal FS to the new containers that will mount against data disks attached to the VM.
To backup the data:
Within container (mongo1):
docker exec -ti mongo1 bash
mongodump --host=mongo1 --port=27011 --username=muser --password=<PASS> --out=/tmp/mongo-backup-2020-03-26
cd /tmptar -zcvf mongo-backup-2020-03-26.tar.gz mongo-backup-2020-03-26/
Outside container:
cd tmp
docker cp mongo1:/tmp/mongo-backup-2020-03-26.tar.gz .
#destroy containers, then outside again
docker stop mongo1 mongo2 mongo3
docker rm mongo1 mongo2 mongo3
#run the ansible playbook to start a new mongo cluster
docker cp mongo-backup-2020-03-26.tar.gz mongo1:/tmp
Inside mongo1:
docker exec -ti mongo1 bash
cd /tmp
tar zxvf mongo-backup-2020-03-26.tar.gzmongorestore --host=mongo1 --port=27011 --username=muser --password=<PASS> --authenticationDatabase=admin /tmp/mongo-backup-2020-03-26
, multiple selections available,
Related content
Running MongoDB as a 3 node cluster (ReplicaSet) in Docker
Running MongoDB as a 3 node cluster (ReplicaSet) in Docker
More like this
2022-01-06 ESR MongoDB cluster down
2022-01-06 ESR MongoDB cluster down
More like this
Migrating Mongo Data (2022)
Migrating Mongo Data (2022)
More like this
2021-09-08 ESR Integration database less resilient
2021-09-08 ESR Integration database less resilient
More like this
2022-05-05 Mongo database failure
2022-05-05 Mongo database failure
More like this
ES sync job temporary workaround
ES sync job temporary workaround
More like this
Slack: https://hee-nhs-tis.slack.com/
Jira issues: https://hee-tis.atlassian.net/issues/?filter=14213