Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am zennermac on github.
  • I am maccazuke (https://keybase.io/maccazuke) on keybase.
  • I have a public key whose fingerprint is 7FA1 3AE1 CB9A D2F7 D876 2626 96F4 D47B 5B53 A777

To claim this, I am signing this object:

@zennermac
zennermac / mysql-docker.sh
Created May 24, 2019 16:27 — forked from nshtg/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root -pPASSWORD DATABASE > backup.sql
docker exec CONTAINER /usr/bin/mysqldump -u root -pPASSWORD DATABASE | gzip > backup.sql.gz
docker exec CONTAINER /usr/bin/mysqldump -u root -pPASSWORD DATABASE | bzip2 > backup.sql.bz2
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root -pPASSWORD DATABASE
gunzip < backup.sql.gz | docker exec -i CONTAINER /usr/bin/mysql -u root -pPASSWORD DATABASE
bunzip2 < backup.sql.bz2 | docker exec -i CONTAINER /usr/bin/mysql -u root -pPASSWORD DATABASE