32 lines
953 B
Bash
32 lines
953 B
Bash
#!/bin/bash
|
|
export MYSQL_PWD=root
|
|
|
|
if [ -d /data/mysql ]; then
|
|
cp -R /data/mysql /var/lib
|
|
echo "[INFO] -> Restored database to default state"
|
|
else
|
|
# Dump structure
|
|
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
|
|
|
|
# Import changes
|
|
for file in changes/*/*.sql; do
|
|
echo "[INFO] -> Imported ./$file"
|
|
mysql -u root -fc < $file
|
|
done
|
|
|
|
# Import fixtures
|
|
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
|
|
|
|
# Copy dumpted data to volume
|
|
cp -R /var/lib/mysql /data
|
|
|
|
echo "[INFO] -> Dumped database"
|
|
fi |