Skip to content

Instantly share code, notes, and snippets.

@huanpc
Created October 7, 2018 04:08
Show Gist options
  • Save huanpc/c43e84a8a1d7d800911264d3a655de97 to your computer and use it in GitHub Desktop.
Save huanpc/c43e84a8a1d7d800911264d3a655de97 to your computer and use it in GitHub Desktop.
mysql backup by docker
# full backup and crompress
docker exec -it [mysql_container_name] mysqldump -u[user] -p[password] --all-databases --add-drop-database --add-drop-table | gzip > /mysql_backup/db_bk_$(date +%F).gz
# full mysql restore with dropping table before recreating
docker exec -it [mysql_container_name] mysql -u[user] -p[password] < gz -d -c /mysql_backup/db_bk_$(date +%F).gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment