Skip to content

Instantly share code, notes, and snippets.

@TravisBernard
Last active November 25, 2020 15:14
Show Gist options
  • Save TravisBernard/97ddb82e56c8189d0a275cff9862a6ab to your computer and use it in GitHub Desktop.
Save TravisBernard/97ddb82e56c8189d0a275cff9862a6ab to your computer and use it in GitHub Desktop.
Backup and Restore Docker Based Mysql
# Backs up the data from a docker mysql instance to the host machine's file system
docker-compose exec $MACHINEID mysqldump -uuser -ppass --all-databases > /host/machine/path/backup.sql
# Or
docker exec $MACHINEID mysqldump -uuser -ppass --all-databases > /host/machine/path/backup.sql
# Restores a docker based mysql from a backup file on the host machine's file system
docker-compose exec -T $MACHINEID mysql -uuser -ppass < /host/machine/path/backup.sql
# Or
docker exec -i $MACHINEID mysql -uuser -ppass < /host/machine/path/backup.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment