2018-04-30 06:46:41 +00:00
|
|
|
#!/bin/bash
|
2018-08-21 11:38:16 +00:00
|
|
|
export MYSQL_PWD=root
|
2018-04-30 06:46:41 +00:00
|
|
|
|
2018-05-08 09:34:50 +00:00
|
|
|
if [ -d /data/mysql ]; then
|
|
|
|
cp -R /data/mysql /var/lib
|
|
|
|
echo "Restored database to default state"
|
|
|
|
else
|
|
|
|
# Dump structure
|
|
|
|
for file in dump/*-*.sql; do
|
|
|
|
echo "Imported $file"
|
2018-08-21 11:38:16 +00:00
|
|
|
mysql -u root -fc < $file
|
2018-05-08 09:34:50 +00:00
|
|
|
done
|
2018-04-30 06:46:41 +00:00
|
|
|
|
2018-05-08 09:34:50 +00:00
|
|
|
# Import changes
|
|
|
|
for file in changes/*/*.sql; do
|
2018-05-10 12:07:25 +00:00
|
|
|
echo "Imported $file"
|
2018-08-21 11:38:16 +00:00
|
|
|
mysql -u root -fc < $file
|
2018-05-08 09:34:50 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Import fixtures
|
|
|
|
echo "Imported fixtures.sql"
|
2018-08-21 11:38:16 +00:00
|
|
|
mysql -u root -f < dump/fixtures.sql
|
2018-05-08 09:34:50 +00:00
|
|
|
|
|
|
|
# Copy dumpted data to volume
|
|
|
|
cp -R /var/lib/mysql /data
|
|
|
|
fi
|