Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rupakg/16bc52c8026b9ee66ebeb5d1ec1638e5 to your computer and use it in GitHub Desktop.
Save rupakg/16bc52c8026b9ee66ebeb5d1ec1638e5 to your computer and use it in GitHub Desktop.
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