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.
Revisions
-
rupakg revised this gist
Nov 18, 2019 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ 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 @@ -12,9 +13,12 @@ docker container id - 8c37a950839a # 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 -
vemuruadi revised this gist
Sep 27, 2019 . 1 changed file with 13 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,19 @@ docker container id - 8c37a950839a # 1. Copy Mongo dump to container folder (Local System)$ docker cp dump/reaction 8c37a950839a:/var/backups/reaction # 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)$ show dbs -> use reaction -> db.dropDatabase() -> exit (Container)$ # 5. Restore dump inside container to Mongodb from the container shell (Container)$ mongorestore -d reaction var/backups/db -
vemuruadi revised this gist
Sep 27, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,5 +7,5 @@ docker container id - 8c37a950839a # 2. Connect to mongodb docker container - docker exec -it 8c37a950839a /bin/bash # 3. Restore dump inaside container to Mongodb - mongorestore -d reaction var/backups/db -
vemuruadi revised this gist
Sep 20, 2019 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,11 @@ docker container id - 8c37a950839a # 1. Copy Mongo dump to container folder - docker cp dump/db 8c37a950839a:/var/backups/db # 2. Connect to mongodb docker container - docker exec -it 8c37a950839a /bin/bash # 3. Restore dump inaside container to Mongodb - mongorestore -d db var/backups/db -
vemuruadi created this gist
Sep 17, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ docker container id - 8c37a950839a # Connect to mongodb container - docker exec -it 8c37a950839a /bin/bash # Copy dump to container - docker cp dump/db 8c37a950839a:/var/backups/db # Restore dump to Mongodb - mongorestore -d db var/backups/db