Created
December 17, 2020 21:27
-
-
Save sethfischer/60438bf3ccae8f6791478356e746a648 to your computer and use it in GitHub Desktop.
Restore MySQL database into a Docker container showing progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Database dump is compressed with this command | |
# xz --keep --compress mysql-dump.sql | |
# Drop and create database | |
docker exec -e "MYSQL_PWD=password" -i project_mysql_1 mysql -uroot <<< "DROP DATABASE database_name;" | |
docker exec -e "MYSQL_PWD=password" -i project_mysql_1 mysql -uroot <<< "CREATE DATABASE database_name;" | |
docker exec -e "MYSQL_PWD=password" -i project_mysql_1 mysql -uroot <<< "SHOW DATABASES;" | |
# Restore database | |
pv mysql-dump.sql.xz | xz --decompress --stdout | docker exec -e "MYSQL_PWD=password" -i project_mysql_1 mysql -uroot database_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment