From df5c7be583de664339c1bd6c8f93f1e7f5d86c7a Mon Sep 17 00:00:00 2001 From: Sergiy Markin Date: Wed, 10 Dec 2025 22:00:17 +0000 Subject: [PATCH] Fix mariadb backup script Change-Id: I6032bfe9504a429bdcc3cfcc6d66098e749ef726 Signed-off-by: Sergiy Markin --- mariadb-backup/templates/bin/_backup_mariadb.sh.tpl | 12 ++++++------ mariadb-backup/templates/bin/_restore_mariadb.sh.tpl | 8 ++++---- mariadb/templates/bin/_backup_mariadb.sh.tpl | 2 +- mariadb/templates/bin/_restore_mariadb.sh.tpl | 4 ++-- .../notes/mariadb-backup-af891fea0cfa3db5.yaml | 5 +++++ releasenotes/notes/mariadb-dcd35d40fcd4a749.yaml | 5 +++++ 6 files changed, 23 insertions(+), 13 deletions(-) mode change 100755 => 100644 mariadb-backup/templates/bin/_restore_mariadb.sh.tpl create mode 100644 releasenotes/notes/mariadb-backup-af891fea0cfa3db5.yaml create mode 100644 releasenotes/notes/mariadb-dcd35d40fcd4a749.yaml diff --git a/mariadb-backup/templates/bin/_backup_mariadb.sh.tpl b/mariadb-backup/templates/bin/_backup_mariadb.sh.tpl index 44db641420..4806453071 100644 --- a/mariadb-backup/templates/bin/_backup_mariadb.sh.tpl +++ b/mariadb-backup/templates/bin/_backup_mariadb.sh.tpl @@ -35,11 +35,11 @@ dump_databases_to_directory() { SCOPE=${3:-"all"} - MYSQL="mysql \ + MYSQL="mariadb \ --defaults-file=/etc/mysql/admin_user.cnf \ --connect-timeout 10" - MYSQLDUMP="mysqldump \ + MYSQLDUMP="mariadb-dump \ --defaults-file=/etc/mysql/admin_user.cnf" if [[ "${SCOPE}" == "all" ]]; then @@ -441,11 +441,11 @@ verify_databases_backup_archives() { export ARCHIVE_DIR=${MARIADB_BACKUP_BASE_DIR}/db/${MARIADB_POD_NAMESPACE}/${DB_NAME}/archive export BAD_ARCHIVE_DIR=${ARCHIVE_DIR}/quarantine export MYSQL_OPTS="--silent --skip-column-names" - export MYSQL_LIVE="mysql ${MYSQL_OPTS}" + export MYSQL_LIVE="mariadb ${MYSQL_OPTS}" export MYSQL_LOCAL_OPTS="" - export MYSQL_LOCAL_SHORT="mysql ${MYSQL_LOCAL_OPTS} --connect-timeout 2" + export MYSQL_LOCAL_SHORT="mariadb ${MYSQL_LOCAL_OPTS} --connect-timeout 2" export MYSQL_LOCAL_SHORT_SILENT="${MYSQL_LOCAL_SHORT} ${MYSQL_OPTS}" - export MYSQL_LOCAL="mysql ${MYSQL_LOCAL_OPTS} --connect-timeout 10" + export MYSQL_LOCAL="mariadb ${MYSQL_LOCAL_OPTS} --connect-timeout 10" max_wait={{ .Values.conf.mariadb_server.setup_wait.iteration }} duration={{ .Values.conf.mariadb_server.setup_wait.duration }} @@ -513,7 +513,7 @@ verify_databases_backup_archives() { # Before insert the tuple mentioned above, we should make sure that the MariaDB version is 10.4.+ mariadb_version=$($MYSQL_LOCAL_SHORT -e "status" | grep -E '^Server\s+version:') log "Current database ${mariadb_version}" - if [[ ! -z ${mariadb_version} && -z $(grep '10.2' <<< ${mariadb_version}}) ]]; then + if [[ ! -z ${mariadb_version} && -z $(grep '10.2' <<< ${mariadb_version}) ]]; then if [[ -z $(grep 'mariadb.sys' <<< $($MYSQL_LOCAL_SHORT mysql -e "select * from global_priv where user='mariadb.sys'")) ]]; then $MYSQL_LOCAL_SHORT -e "insert into mysql.global_priv values ('localhost','mariadb.sys',\ '{\"access\":0,\"plugin\":\"mysql_native_password\",\"authentication_string\":\"\",\"account_locked\":true,\"password_last_changed\":0}');" diff --git a/mariadb-backup/templates/bin/_restore_mariadb.sh.tpl b/mariadb-backup/templates/bin/_restore_mariadb.sh.tpl old mode 100755 new mode 100644 index 334ba85bc6..32e639344c --- a/mariadb-backup/templates/bin/_restore_mariadb.sh.tpl +++ b/mariadb-backup/templates/bin/_restore_mariadb.sh.tpl @@ -35,17 +35,17 @@ RESTORE_LOG='/tmp/restore_error.log' rm -f $RESTORE_LOG # This is for commands which require admin access -MYSQL="mysql \ +MYSQL="mariadb \ --defaults-file=/etc/mysql/admin_user.cnf \ - --host=$MARIADB_SERVER_SERVICE_HOST \ --connect-timeout 10" # This is for commands which we want the temporary "restore" user # to execute -RESTORE_CMD="mysql \ +RESTORE_CMD="mariadb \ --user=${RESTORE_USER} \ --password=${RESTORE_PW} \ - --host=$MARIADB_SERVER_SERVICE_HOST \ + --host={{ tuple "oslo_db" "direct" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} \ + --port={{ tuple "oslo_db" "direct" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} \ {{- if .Values.manifests.certificates }} --ssl-ca=/etc/mysql/certs/ca.crt \ --ssl-key=/etc/mysql/certs/tls.key \ diff --git a/mariadb/templates/bin/_backup_mariadb.sh.tpl b/mariadb/templates/bin/_backup_mariadb.sh.tpl index 7514b0c4e3..4806453071 100644 --- a/mariadb/templates/bin/_backup_mariadb.sh.tpl +++ b/mariadb/templates/bin/_backup_mariadb.sh.tpl @@ -514,7 +514,7 @@ verify_databases_backup_archives() { mariadb_version=$($MYSQL_LOCAL_SHORT -e "status" | grep -E '^Server\s+version:') log "Current database ${mariadb_version}" if [[ ! -z ${mariadb_version} && -z $(grep '10.2' <<< ${mariadb_version}) ]]; then - if [[ -z $(grep 'mariadb.sys' <<< $($MYSQL_LOCAL_SHORT mariadb -e "select * from global_priv where user='mariadb.sys'")) ]]; then + if [[ -z $(grep 'mariadb.sys' <<< $($MYSQL_LOCAL_SHORT mysql -e "select * from global_priv where user='mariadb.sys'")) ]]; then $MYSQL_LOCAL_SHORT -e "insert into mysql.global_priv values ('localhost','mariadb.sys',\ '{\"access\":0,\"plugin\":\"mysql_native_password\",\"authentication_string\":\"\",\"account_locked\":true,\"password_last_changed\":0}');" $MYSQL_LOCAL_SHORT -e 'flush privileges;' diff --git a/mariadb/templates/bin/_restore_mariadb.sh.tpl b/mariadb/templates/bin/_restore_mariadb.sh.tpl index c0c04dc772..32e639344c 100644 --- a/mariadb/templates/bin/_restore_mariadb.sh.tpl +++ b/mariadb/templates/bin/_restore_mariadb.sh.tpl @@ -37,7 +37,6 @@ rm -f $RESTORE_LOG # This is for commands which require admin access MYSQL="mariadb \ --defaults-file=/etc/mysql/admin_user.cnf \ - --host=$MARIADB_SERVER_SERVICE_HOST \ --connect-timeout 10" # This is for commands which we want the temporary "restore" user @@ -45,7 +44,8 @@ MYSQL="mariadb \ RESTORE_CMD="mariadb \ --user=${RESTORE_USER} \ --password=${RESTORE_PW} \ - --host=$MARIADB_SERVER_SERVICE_HOST \ + --host={{ tuple "oslo_db" "direct" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} \ + --port={{ tuple "oslo_db" "direct" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} \ {{- if .Values.manifests.certificates }} --ssl-ca=/etc/mysql/certs/ca.crt \ --ssl-key=/etc/mysql/certs/tls.key \ diff --git a/releasenotes/notes/mariadb-backup-af891fea0cfa3db5.yaml b/releasenotes/notes/mariadb-backup-af891fea0cfa3db5.yaml new file mode 100644 index 0000000000..0ae5d61715 --- /dev/null +++ b/releasenotes/notes/mariadb-backup-af891fea0cfa3db5.yaml @@ -0,0 +1,5 @@ +--- +mariadb: + - | + - fixed backup_mariadb_sh script to correctly handle verification during the backup process +... diff --git a/releasenotes/notes/mariadb-dcd35d40fcd4a749.yaml b/releasenotes/notes/mariadb-dcd35d40fcd4a749.yaml new file mode 100644 index 0000000000..0ae5d61715 --- /dev/null +++ b/releasenotes/notes/mariadb-dcd35d40fcd4a749.yaml @@ -0,0 +1,5 @@ +--- +mariadb: + - | + - fixed backup_mariadb_sh script to correctly handle verification during the backup process +...