Skip to content

Instantly share code, notes, and snippets.

@lzarus
Forked from ipedrazas/dump
Created March 25, 2020 08:06
Show Gist options
  • Save lzarus/2f35973a98e9fd7612ebb88d24ec2c5b to your computer and use it in GitHub Desktop.
Save lzarus/2f35973a98e9fd7612ebb88d24ec2c5b 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’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment