#!/bin/bash export MYSQL_PWD=root 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" mysql -u root -fc < $file done # Import changes for file in changes/*/*.sql; do echo "Imported $file" mysql -u root -fc < $file done # Import fixtures echo "Imported fixtures.sql" mysql -u root -f < dump/fixtures.sql # Copy dumpted data to volume cp -R /var/lib/mysql /data fi