Skip to content

Commit

Permalink
Compatibility with MariaDB which uses "extra files" instead of "login…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kekos committed Sep 18, 2022
1 parent 0b88c34 commit 31cad9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 13 additions & 6 deletions automysqlbackup
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ load_default_config() {
CONFIG_mysql_dump_dbstatus='yes'
CONFIG_mysql_dump_differential='no'
CONFIG_mysql_dump_login_path='automysqldump'
CONFIG_mysql_dump_login_path_file=''
CONFIG_mysql_dump_login_path_file='automysqldump'
CONFIG_mysql_dump_config_extra_file=''
CONFIG_mysql_dump_encrypted_login='no'
CONFIG_backup_local_files=()
CONFIG_db_names=()
Expand Down Expand Up @@ -113,11 +114,17 @@ mysql_commands() {
VERSION=`mysql -V | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"`
NODOT_VER=`echo $VERSION | sed $OS_sed_option 's/\.//g'`
if [ "${CONFIG_mysql_dump_encrypted_login}" = "yes" ]; then
export MYSQLDUMP="mysqldump --login-path=$CONFIG_mysql_dump_login_path"
export MYSQLSHOW="mysqlshow --login-path=$CONFIG_mysql_dump_login_path"
export MYSQL="mysql --login-path=$CONFIG_mysql_dump_login_path"
if [ -n "${CONFIG_mysql_dump_login_path_file}" ]; then
export MYSQL_TEST_LOGIN_FILE=$CONFIG_mysql_dump_login_path_file
if [ "${CONFIG_mysql_dump_config_extra_file}" != "" ]; then
export MYSQLDUMP="mysqldump --defaults-extra-file=$CONFIG_mysql_dump_config_extra_file"
export MYSQLSHOW="mysqlshow --defaults-extra-file=$CONFIG_mysql_dump_config_extra_file"
export MYSQL="mysql --defaults-extra-file=$CONFIG_mysql_dump_config_extra_file"
else
export MYSQLDUMP="mysqldump --login-path=$CONFIG_mysql_dump_login_path"
export MYSQLSHOW="mysqlshow --login-path=$CONFIG_mysql_dump_login_path"
export MYSQL="mysql --login-path=$CONFIG_mysql_dump_login_path"
if [ -n "${CONFIG_mysql_dump_login_path_file}" ]; then
export MYSQL_TEST_LOGIN_FILE=$CONFIG_mysql_dump_login_path_file
fi
fi
else
export MYSQLDUMP="mysqldump --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
Expand Down
4 changes: 4 additions & 0 deletions automysqlbackup.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
# The path to file where "login path" is stored
#CONFIG_mysql_dump_login_path_file=''

# If connecting to a MariaDB server, use the following "extra file" instead of "login path"
# Read more at https://mariadb.com/kb/en/mysql_config_editor-compatibility/
#CONFIG_mysql_dump_config_extra_file='automysqldump'

# Host name (or IP address) of MySQL server e.g localhost
#CONFIG_mysql_dump_host='localhost'

Expand Down

0 comments on commit 31cad9e

Please sign in to comment.