#!/bin/bash







SQL_DUMP_FILE=/root/all_tables_4.1.0.sql
./mysql -uroot -pQzfXQhd3bQ -h127.0.0.1 -P33306 -e 'show databases;' | grep -Ev 'Database|information_schema|mysql|sys|performance_schema' | xargs ./mysqldump -uroot -pQzfXQhd3bQ -h127.0.0.1 -P33306 --single-transaction  --source-data=2 --hex-blob --triggers --routines --events --no-data --set-gtid-purged=OFF --databases  > "${SQL_DUMP_FILE}"


SQL_FULL_BACK_UP_FILE=/home/mmc/all_tables_4.0.2_230914_fullback.sql
./mysql -uroot -pQzfXQhd3bQ -h127.0.0.1 -P33306 -e 'show databases;' | grep -Ev 'Database|information_schema|mysql|sys|performance_schema' | xargs ./mysqldump -uroot -pQzfXQhd3bQ -h127.0.0.1 -P33306 --single-transaction  --source-data=2 --hex-blob --triggers --routines --events --set-gtid-purged=OFF --databases  > "${SQL_FULL_BACK_UP_FILE}"

NEW_UPDATED_SQL_FILE_FOLDER=/home/mmc/4.1.6-sql-update
for sql_file in $(ls ${NEW_UPDATED_SQL_FILE_FOLDER}); do
    echo "current file is ${sql_file}"
    ./mysql -uroot -pQzfXQhd3bQ -h127.0.0.1 -P33306 <"$NEW_UPDATED_SQL_FILE_FOLDER/${sql_file}"
    echo "------------------"
    echo ""
done


./mysql -uroot -pQzfXQhd3bQ -h127.0.0.1 -P33306



