salix/services/db/install/boot.sh

32 lines
953 B
Bash
Raw Normal View History

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
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"
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
# 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
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
# Copy dumpted data to volume
cp -R /var/lib/mysql /data
2018-10-08 11:37:57 +00:00
echo "[INFO] -> Dumped database"
fi