Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ CONFIG_do_weekly="5"
CONFIG_rotation_daily=6
CONFIG_rotation_weekly=35
CONFIG_rotation_monthly=150
CONFIG_mysql_bin=''
CONFIG_mysqldump_bin=''
CONFIG_mysqlshow_bin=''
CONFIG_mysql_dump_usessl='yes'
CONFIG_mysql_dump_username='root'
CONFIG_mysql_dump_password=''
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Adjustments
-----------

You can find some original files from the sourceforge package. Some files are adjusted to my needs:
- support for MySQL 5.6 and MySQL 5.7
- support for MySQL 5.6, MySQL 5.7 and MariaDB
- support for login path (since MySQL 5.6.x a secure way to save your mysql credentials was implemented)
- adjusted the use of --ssl because it became depreated in MySQL 5.7. The parameter --ssl-mode=REQUIRED is used instead.

Expand Down
40 changes: 32 additions & 8 deletions automysqlbackup
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ load_default_config() {
CONFIG_rotation_daily=6
CONFIG_rotation_weekly=35
CONFIG_rotation_monthly=150
CONFIG_mysql_bin=''
CONFIG_mysqldump_bin=''
CONFIG_mysqlshow_bin=''
CONFIG_mysql_dump_port=3306
CONFIG_mysql_dump_usessl='no'
CONFIG_mysql_dump_username='root'
Expand Down Expand Up @@ -118,19 +121,30 @@ load_default_config() {
}

mysql_commands() {
VERSION=`mysql -V | grep -oE "[0-9]+\.[0-9]+\.[0-9]+" | head -1`
# Detect MariaDB or use MySQL
if isMariaDB; then
[[ -z "${CONFIG_mysql_bin}" ]] && CONFIG_mysql_bin='mariadb'
[[ -z "${CONFIG_mysqldump_bin}" ]] && CONFIG_mysqldump_bin='mariadb-dump'
[[ -z "${CONFIG_mysqlshow_bin}" ]] && CONFIG_mysqlshow_bin='mariadb-show'
else
[[ -z "${CONFIG_mysql_bin}" ]] && CONFIG_mysql_bin='mysql'
[[ -z "${CONFIG_mysqldump_bin}" ]] && CONFIG_mysqldump_bin='mysqldump'
[[ -z "${CONFIG_mysqlshow_bin}" ]] && CONFIG_mysqlshow_bin='mysqlshow'
fi

VERSION=`${CONFIG_mysql_bin} -V | grep -oE "[0-9]+\.[0-9]+\.[0-9]+" | head -1`
NODOT_VER=`echo $VERSION | sed -${sed_Regex} '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"
export MYSQLDUMP="${CONFIG_mysqldump_bin} --login-path=$CONFIG_mysql_dump_login_path"
export MYSQLSHOW="${CONFIG_mysqlshow_bin} --login-path=$CONFIG_mysql_dump_login_path"
export MYSQL="${CONFIG_mysql_bin} --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
else
export MYSQLDUMP="mysqldump --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
export MYSQLSHOW="mysqlshow --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
export MYSQL="mysql --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
export MYSQLDUMP="${CONFIG_mysqldump_bin} --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
export MYSQLSHOW="${CONFIG_mysqlshow_bin} --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
export MYSQL="${CONFIG_mysql_bin} --user=${CONFIG_mysql_dump_username} --password=${CONFIG_mysql_dump_password} --host=${CONFIG_mysql_dump_host}";
fi
}

Expand All @@ -144,6 +158,12 @@ isEmpty() {
if [[ ${!1} ]]; then return 1; else return 0; fi
}

# @return: true, if mariadb is installed; else false
isMariaDB() {
type mariadb &>/dev/null
return $?
}

# @info: Called when one of the signals EXIT, SIGHUP, SIGINT, SIGQUIT or SIGTERM is emitted.
# It removes the IO redirection, mails any log file information and cleans up any temporary files.
# @args: (none)
Expand Down Expand Up @@ -1210,7 +1230,11 @@ cleanup_latest () {
check_dependencies () {
echo
echo "# Testing for installed programs"
dependencies=( 'mysql' 'mysqldump' )
if isMariaDB; then
dependencies=( 'mariadb' 'mariadb-dump' )
else
dependencies=( 'mysql' 'mysqldump' )
fi

if [[ "x$CONFIG_multicore" = 'xyes' ]]; then

Expand Down
6 changes: 6 additions & 0 deletions automysqlbackup.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

# Basic Settings

# Override the client binary names if auto-detection produces wrong results.
# When unset, the script auto-detects binaries for MariaDB and MySQL.
#CONFIG_mysql_bin=''
#CONFIG_mysqldump_bin=''
#CONFIG_mysqlshow_bin=''

# use encrypted authentication credentials
# yes: through login path
# no: through username and password
Expand Down