thesnowmancometh
6/29/2018 - 8:04 PM

Backup MySQL inside Docker

If you have a MySQL instance running inside of the container, and you don't have the luxury of persisting the volume to disk, try this snippet out. It will backup and restore a MySQL database running inside of a container.

# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE