[Windows] Back up & restore MySQL data from Docker container
Mar 17, 2020
This post will help you to save your time.
Back Up
C:\docker\directory> docker psC:\docker\directory> docker exec container-id /usr/bin/mysqldump -u username database-name > dump.sql
Restore
C:\docker\directory> docker psC:\docker\directory> docker exec -i container-id /usr/bin/mysql -u username database-name < dump.sql
If you want to use docker-compose command…
# To back backup
C:\docker\directory> docker-compose exec -T container-name /usr/bin/mysqldump -u username database-name > dump.sql# to rollback
C:\docker\directory> docker-compose exec -T container-name /usr/bin/mysql -u username database-name < dump.sql