зеркало из https://github.com/nextcloud/cookbook.git
Merge pull request #2339 from nextcloud/maintenance/fix-ci-tests-mysql
Provide the database name while restoring
This commit is contained in:
Коммит
4ea70d9c2f
|
@ -12,13 +12,27 @@ is_file_dump () {
|
|||
|
||||
restore_mysql_dump () {
|
||||
echo "Dropping old data from the database"
|
||||
mysql -u root -p"$MYSQL_ROOT_PASSWORD" -h mysql <<- EOF | tail -n +2 > /tmp/mysql_tables
|
||||
echo "Getting tables"
|
||||
mariadb -u root -p"$MYSQL_ROOT_PASSWORD" -h mysql "$MYSQL_DATABASE" <<- EOF | tail -n +2 > /tmp/mysql_tables
|
||||
SHOW TABLES;
|
||||
EOF
|
||||
cat /tmp/mysql_tables | sed 's@.*@DROP TABE \0;@' | mysql -u root -p"$MYSQL_ROOT_PASSWORD" -h mysql
|
||||
echo "Got:"
|
||||
cat /tmp/mysql_tables
|
||||
cat /tmp/mysql_tables | sed 's@.*@DROP TABLE \0;@' | mysql -u root -p"$MYSQL_ROOT_PASSWORD" -h mysql "$MYSQL_DATABASE"
|
||||
|
||||
echo "Restoring MySQL from single file dump"
|
||||
mysql -u root -p"$MYSQL_ROOT_PASSWORD" -h mysql < "$SF_DIR/sql/dump.sql"
|
||||
local dump_file="$SF_DIR/sql/dump.sql"
|
||||
if grep 'enable the sandbox mode' "$dump_file" > /dev/null
|
||||
then
|
||||
tail -n +2 "$dump_file" > /tmp/tmpdump.sql
|
||||
else
|
||||
cat "$dump_file" > /tmp/tmpdump.sql
|
||||
fi
|
||||
head "/tmp/tmpdump.sql"
|
||||
echo "Version:"
|
||||
mysql --version
|
||||
echo "Carrying out..."
|
||||
mariadb -u root -p"$MYSQL_ROOT_PASSWORD" -h mysql "$MYSQL_DATABASE" < "/tmp/tmpdump.sql"
|
||||
}
|
||||
|
||||
restore_postgres_dump () {
|
||||
|
|
Загрузка…
Ссылка в новой задаче