Skip to content

Instantly share code, notes, and snippets.

@lucatume
Created September 28, 2018 06:16
Show Gist options
  • Save lucatume/c053e4006cc1c5db42c1d5f876cfc37c to your computer and use it in GitHub Desktop.
Save lucatume/c053e4006cc1c5db42c1d5f876cfc37c to your computer and use it in GitHub Desktop.
Restore Local by Flywheel db from import files
#!/bin/bash
db_user=root
db_pass=root
db_host="192.168.92.100"
db_port="4018"
dbs=("local" "wordpress")
for db in ${dbs[@]}; do
mysql -u ${db_user} -p${db_pass} -h${db_host} -P${db_port} -e "drop database if exists $db"
mysql -u ${db_user} -p${db_pass} -h${db_host} -P${db_port} -e "create database $db"
for f in $(find . -name "${db}*-schema.sql"); do
mysql -u${db_user} -p${db_pass} -h${db_host} -P${db_port} $db < $f
done
for f in $(find . -type f \( -name "${db}*.sql" ! -iname "${db}*-schema.sql" \)); do
mysql -u${db_user} -p${db_pass} -h${db_host} -P${db_port} $db < $f
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment