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
|
2018-10-08 11:37:57 +00:00
|
|
|
echo "[INFO] -> Restored database to default state"
|
2018-05-08 09:34:50 +00:00
|
|
|
else
|
|
|
|
# Dump structure
|
2018-10-08 11:37:57 +00:00
|
|
|
echo "[INFO] -> Imported ./dump/truncateAll.sql"
|
|
|
|
mysql -u root -f < ./dump/truncateAll.sql
|
|
|
|
echo "[INFO] -> Imported ./dump/structure.sql"
|
|
|
|
mysql -u root -f < ./dump/structure.sql
|
|
|
|
echo "[INFO] -> Imported ./dump/mysqlPlugins.sql"
|
|
|
|
mysql -u root -f < ./dump/mysqlPlugins.sql
|
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-10-08 11:37:57 +00:00
|
|
|
echo "[INFO] -> 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
|
2018-10-08 11:37:57 +00:00
|
|
|
echo "[INFO] -> Imported ./dump/dumpedFixtures.sql"
|
|
|
|
mysql -u root -f < ./dump/dumpedFixtures.sql
|
|
|
|
echo "[INFO] -> Imported ./dump/fixtures.sql"
|
|
|
|
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
|
2018-10-08 11:37:57 +00:00
|
|
|
|
|
|
|
echo "[INFO] -> Dumped database"
|
2018-05-08 09:34:50 +00:00
|
|
|
fi
|