### Backup mongo db container on docker host
```
docker run --rm --network [network] --link [db_container]:mongo -v /Users/sam/db_backups:/backup mongo bash -c 'mongodump -u [username] -p [password] --out /backup --host mongo:27017'
```
### Restore mongodb database
```
docker run --rm --network [network] --link [db_container]:mongo -v /Users/sam/db_backups:/backup mongo bash -c 'mongorestore -u [mong_username] -p [mong_password] /backup --host mongo:27017'
```
The restore will wipe everything that existed before-hand.
Comments
Post a Comment