#!/bin/sh VERSION="v2021102000" # /root/bin/mysqldump.sh -p 3306 -d "testdb1 testdb2 testdb3" | gzip -9 > /tmp/testdbs.sql.gz # /root/bin/mysqldump.sh -p 3306 -l -d "testdb1 testdb2 testdb3" | gzip -9 > /tmp/testdbs.sql.gz # /root/bin/mysqldump.sh -p 3306 -l -t löschen -d "testdb1 testdb2 testdb3" | gzip -9 > /tmp/testdbs.sql.gz # /root/bin/mysqldump.sh -p 3306 -t löschen -d "testdb1 testdb2 testdb3" | gzip -9 > /tmp/testdbs.sql.gz # /root/bin/mysqldump.sh -h 192.168.1.100 -p 3306 -d "testdb1 testdb2 testdb3" | gzip -9 > /tmp/testdbs.sql.gz while [ "${#}" -ne "0" ]; do case "${1}" in -h) HOST=${2} shift ;; -p) PORT=${2} shift ;; -t) TABELLEN=${2} shift ;; -d) DATENBANKEN=${2} shift ;; -l) LEER=${2} shift ;; -h) echo " HILFE: ${0} [Option] DB-Host: -h [Hostname] DB-Port: -p [Port] Tabellen vorher löschen: -t löschen Datenbanken: -d [Datenbanken] ohne Daten: -l ${0} -p 3306 -d \"testdb1 testdb2 testdb3\" ${0} -p 3306 -t löschen -d \"testdb1 testdb2 testdb3\" ${0} -p 3306 -l -d \"testdb1 testdb2 testdb3\" ${0} -h 192.168.1.100 -p 3306 -d \"testdb1 testdb2 testdb3\" " exit 1 ;; *) if [ "$(echo "${1}"|egrep '^-')" ] ; then echo "Der Parameter '${1}' wird nicht unterstützt!" fi shift ;; esac done if [ "x${HOST}" == "x" ] ; then #HOST="localhost" HOST="127.0.0.1" fi if [ "x${PORT}" == "x" ] ; then echo "${0} -h" echo "${0} -p 3306 ..." exit 11 fi if [ "x${LEER}" == "x" ] ; then LEER="-d" fi if [ "${TABELLEN}" == "löschen" ] ; then DROP_TABLE="--add-drop-table" # Tabellen löschen else DROP_TABLE="--skip-add-drop-table" # Tabellen nicht löschen fi DBS="$(for D_B in ${DATENBANKEN} do echo -n "-B ${D_B} " done)" mysqldump -h ${HOST} -P ${PORT} --set-gtid-purged=OFF --opt --triggers --routines ${DROP_TABLE} --order-by-primary --single-transaction --skip-extended-insert -QEc ${LEER} ${DBS}