Forked from vemuruadi/Restore backup db to MongoDB Docker Container
Last active
December 22, 2023 11:16
-
-
Save rupakg/16bc52c8026b9ee66ebeb5d1ec1638e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker container id - 8c37a950839a | |
# Make sure that the `/var/backups` folder is clean inside the container | |
# 1. Copy Mongo dump to container folder | |
(Local System)$ docker cp dump/reaction 8c37a950839a:/var/backups | |
# 2. Connect to mongodb docker container | |
(Local System)$ docker exec -it 8c37a950839a /bin/bash | |
# 3. Check if backup is copied to docker container | |
(Container)$ ls var/backups/reaction | |
# 4. Drop Database | |
(Container)$ mongo | |
(Container->Mongo shell)$ show dbs | |
use reaction | |
db.dropDatabase() | |
exit | |
(Container)$ | |
# 5. Restore dump inside container to Mongodb from the container shell root folder | |
(Container)$ mongorestore -d reaction var/backups/reaction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment