@@ -1029,13 +1029,27 @@ function backup_method_pgsql()
1029
1029
function backup_method_mysql()
1030
1030
{
1031
1031
method=" $1 "
1032
+ backup_method_mysql_mariadb $method $mysqldump $mysql
1033
+ }
1034
+
1035
+ function backup_method_mariadb() {
1036
+ method=" $1 "
1037
+ backup_method_mysql_mariadb $method $mariadbdump $mariadb
1038
+ }
1039
+
1040
+
1041
+ function backup_method_mysql_mariadb()
1042
+ {
1043
+ method=" $1 "
1044
+ dump_bin=" $2 "
1045
+ client_bin=" $3 "
1032
1046
mysql_conffile=" $HOME /.backup-manager_my.cnf"
1033
1047
1034
1048
debug " backup_method_mysql ($method )"
1035
1049
1036
1050
info " Using method \"\$ method\" ."
1037
- if [[ ! -x $mysqldump ]]; then
1038
- error " The \" mysql \ " method is chosen, but \$ mysqldump is not found."
1051
+ if [[ ! -x $dump_bin ]]; then
1052
+ error " The \"\$ method \ " method is chosen, but \$ dump_bin is not found."
1039
1053
fi
1040
1054
1041
1055
opt=" "
@@ -1045,28 +1059,29 @@ function backup_method_mysql()
1045
1059
1046
1060
# if a MySQL Client conffile exists, the password must be inside
1047
1061
if [[ -f $mysql_conffile ]]; then
1048
- info " Using existing MySQL client configuration file: \$ mysql_conffile"
1062
+ info " Using existing MySQL/MariaDB client configuration file: \$ mysql_conffile"
1049
1063
BM_SHOULD_PURGE_MYCNF=" false"
1050
1064
# we create a default one, just with the password
1051
1065
else
1052
- warning " Creating a default MySQL client configuration file: \$ mysql_conffile"
1066
+ warning " Creating a default MySQL/MariaDB client configuration file: \$ mysql_conffile"
1053
1067
echo " [client]" > $mysql_conffile
1054
- echo " # The following password will be sent to all standard MySQL clients" >> $mysql_conffile
1068
+ echo " # The following password will be sent to all standard MySQL/MariaDB clients" >> $mysql_conffile
1055
1069
chmod 600 $mysql_conffile
1056
1070
echo " password=\" $BM_MYSQL_ADMINPASS \" " >> $mysql_conffile
1057
1071
BM_SHOULD_PURGE_MYCNF=" true"
1058
1072
fi
1059
- base_command=" $mysqldump --defaults-extra-file=$mysql_conffile $opt -u$BM_MYSQL_ADMINLOGIN -h$BM_MYSQL_HOST -P$BM_MYSQL_PORT $BM_MYSQL_EXTRA_OPTIONS "
1073
+ if [ -n " $BM_MYSQL_PORT " ]; then BM_MYSQL_PORT_OPT=" -P$BM_MYSQL_PORT " ; else BM_MYSQL_PORT_OPT=" " ; fi
1074
+ base_command=" $dump_bin --defaults-extra-file=$mysql_conffile $opt -u$BM_MYSQL_ADMINLOGIN -h$BM_MYSQL_HOST $BM_MYSQL_PORT_OPT $BM_MYSQL_EXTRA_OPTIONS "
1060
1075
compress=" $BM_MYSQL_FILETYPE "
1061
1076
1062
1077
# get each DB name if backing up separately
1063
1078
if [ " $BM_MYSQL_DATABASES " = " __ALL__" ]; then
1064
1079
if [ " $BM_MYSQL_SEPARATELY " = " true" ]; then
1065
- if [[ ! -x $mysql ]]; then
1066
- error " Can't find " $mysql " but this is needed when backing up databases separately."
1080
+ if [[ ! -x $client_bin ]]; then
1081
+ error " Can't find \"\$ client_bin \ " but this is needed when backing up databases separately."
1067
1082
fi
1068
1083
1069
- DBNAMES=$( $mysql --defaults-extra-file=$mysql_conffile -u $BM_MYSQL_ADMINLOGIN -h $BM_MYSQL_HOST -P $BM_MYSQL_PORT -B -N -e " show databases" | sed ' s/ /%/g' )
1084
+ DBNAMES=$( $client_bin --defaults-extra-file=$mysql_conffile -u $BM_MYSQL_ADMINLOGIN -h $BM_MYSQL_HOST $BM_MYSQL_PORT_OPT -B -N -e " show databases" | sed ' s/ /%/g' )
1070
1085
1071
1086
# if DBs are excluded
1072
1087
for exclude in $BM_MYSQL_DBEXCLUDE
@@ -1081,10 +1096,10 @@ function backup_method_mysql()
1081
1096
for database in $BM_MYSQL_DATABASES
1082
1097
do
1083
1098
if [[ " $database " = " __ALL__" ]]; then
1084
- file_to_create=" $BM_REPOSITORY_ROOT /${BM_ARCHIVE_PREFIX} -all-mysql -databases.$TODAY .sql"
1099
+ file_to_create=" $BM_REPOSITORY_ROOT /${BM_ARCHIVE_PREFIX} -all-${method} -databases.$TODAY .sql"
1085
1100
command=" $base_command --all-databases"
1086
1101
else
1087
- file_to_create=" $BM_REPOSITORY_ROOT /${BM_ARCHIVE_PREFIX} -mysql -${database} .$TODAY .sql"
1102
+ file_to_create=" $BM_REPOSITORY_ROOT /${BM_ARCHIVE_PREFIX} -${method} -${database} .$TODAY .sql"
1088
1103
command=" $base_command $database "
1089
1104
fi
1090
1105
__create_file_with_meta_command
0 commit comments