#docker #mongo
Dump Mongo from a Container
This command assumes you have:
- a container named mongo
- a database named mydb
- a user named root with a password of root
- a volume mounted at /mongo-backup
TIMESTAMP=$(date '+%Y%m%d-%H%M%S')
docker-compose exec -T mongo bash -c "mongodump --authenticationDatabase=admin --username=root --password=root --out=/mongo-backup/dump-$TIMESTAMP --db=mydb"