Skip to content

Instantly share code, notes, and snippets.

@RagedUnicorn
Created August 17, 2018 09:39
Show Gist options
  • Select an option

  • Save RagedUnicorn/00387f150c67be39a1c603425c060cee to your computer and use it in GitHub Desktop.

Select an option

Save RagedUnicorn/00387f150c67be39a1c603425c060cee to your computer and use it in GitHub Desktop.
Docker backup or restory mysql

Docker MySQL Backup and Restore

Create a Backup

docker exec [CONTAINER] /usr/bin/mysqldump -u[user] -p[password] [DATABASE] > backup.sql

Restore a Backup

cat backup.sql | docker exec -i [CONTAINER] /usr/bin/mysql -u[user] -p[password] [DATABASE]

Note: Container in this case can be either part or the full container id or the full container name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment