Skip to content

Instantly share code, notes, and snippets.

@ipedrazas
Created April 22, 2017 04:10
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save ipedrazas/0efeb519871bff38433ebde54ae423ec to your computer and use it in GitHub Desktop.
Save ipedrazas/0efeb519871bff38433ebde54ae423ec to your computer and use it in GitHub Desktop.
Mongo dump/restore with docker
# Backup DB
docker run \
--rm \
--link running_mongo:mongo \
-v /data/mongo/backup:/backup \
mongo \
bash -c ‘mongodump --out /backup --host $MONGO_PORT_27017_TCP_ADDR’
# Download the dump
scp -r USER@REMOTE:/data/mongo/backup ./backup
# Restore DB
# upload file
scp -r ./backup USER@REMOTE:/data/mongo/backup
docker run \
--rm \
--link running_mongo:mongo \
-v /data/mongodb/backup:/backup \
mongo \
bash -c ‘mongorestore /backup --host $MONGO_PORT_27017_TCP_ADDR’
@jeromejaglale
Copy link

@gerroon
Copy link

gerroon commented Dec 24, 2019

@jeromejaglale

I get EOF error with restore, it seems like other people have this issue with your lines. Are you sure the restore or the dump is done properly this way?

@adsi7698
Copy link

@jeromejaglale
I get EOF error cause my dump is a directory. What to do?

@adsi7698
Copy link

Hey @ipedrazas,
Can you help me in explaining your command. Not sure, getting error -
/backup’: $'\342\200\230mongorestore': command not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment