Skip to content

Instantly share code, notes, and snippets.

@codemation
Forked from spalladino/mysql-docker.sh
Last active January 17, 2021 14:42
Show Gist options
  • Select an option

  • Save codemation/1529d44ef7b73cb4c458bf5bb281f107 to your computer and use it in GitHub Desktop.

Select an option

Save codemation/1529d44ef7b73cb4c458bf5bb281f107 to your computer and use it in GitHub Desktop.

Revisions

  1. codemation revised this gist Jan 17, 2021. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions mysql-docker.sh
    Original file line number Diff line number Diff line change
    @@ -5,5 +5,4 @@ docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > back
    cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE

    # Restore into Kubernetes

    kubectl -n namespace exec -i my_sql_pod_name -- mysql -u user -ppassword < backup.sql
    cat backup.sql | kubectl exec -n <destination_namespace> -i <destination_pod> -- mysql -u root --password='password' <destination_database>
  2. codemation revised this gist Jan 17, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions mysql-docker.sh
    Original file line number Diff line number Diff line change
    @@ -4,3 +4,6 @@ docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > back
    # Restore
    cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE

    # Restore into Kubernetes

    kubectl -n namespace exec -i my_sql_pod_name -- mysql -u user -ppassword < backup.sql
  3. Santiago Palladino created this gist Dec 22, 2015.
    6 changes: 6 additions & 0 deletions mysql-docker.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # 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