2020-11-14 01:38:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
CONFIG_FILE=$1
|
|
|
|
INI_FILE=$2
|
2020-11-17 10:53:31 +00:00
|
|
|
DUMP_FILE=".dump.sql"
|
2020-11-14 01:38:56 +00:00
|
|
|
|
|
|
|
echo "SELECT 1;" | mysql --defaults-file="$INI_FILE" >> /dev/null
|
2020-11-17 10:53:31 +00:00
|
|
|
SCHEMAS=( $(jq -r ".schemas[]" "$CONFIG_FILE") )
|
|
|
|
|
|
|
|
mysqldump \
|
|
|
|
--defaults-file="$INI_FILE" \
|
|
|
|
--default-character-set=utf8 \
|
|
|
|
--no-data \
|
|
|
|
--comments \
|
|
|
|
--triggers --routines --events \
|
|
|
|
--databases \
|
|
|
|
${SCHEMAS[@]} \
|
|
|
|
| sed 's/ AUTO_INCREMENT=[0-9]* //g' \
|
|
|
|
> "$DUMP_FILE"
|
2020-11-14 01:38:56 +00:00
|
|
|
|
|
|
|
for SCHEMA in $(jq -r ".fixtures | keys[]" "$CONFIG_FILE"); do
|
|
|
|
TABLES=( $(jq -r ".fixtures.$SCHEMA[]" "$CONFIG_FILE") )
|
|
|
|
|
|
|
|
echo "USE \`$SCHEMA\`;" >> "$DUMP_FILE"
|
|
|
|
mysqldump \
|
|
|
|
--defaults-file="$INI_FILE" \
|
|
|
|
--no-create-info \
|
|
|
|
--skip-triggers \
|
|
|
|
$SCHEMA ${TABLES[@]} >> "$DUMP_FILE"
|
|
|
|
done
|