From 37bbc13bfdf2a57b7ae5ce8749bdc1f5570c8cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavi=20Lle=C3=B3=20Tom=C3=A1s?= Date: Wed, 5 Feb 2025 13:05:38 +0100 Subject: [PATCH 1/2] refs #8414 - restore-backup.sh script - Add formatted_date to log start and end of operations --- roles/db/files/mariabackup/restore-backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/db/files/mariabackup/restore-backup.sh b/roles/db/files/mariabackup/restore-backup.sh index f8b612f..e1d458c 100644 --- a/roles/db/files/mariabackup/restore-backup.sh +++ b/roles/db/files/mariabackup/restore-backup.sh @@ -6,6 +6,7 @@ myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" . "$myDir/config.sh" backupFile=$1 +formatted_date=$(date -d "$fecha" +"%Y%m%d") if [ -z "$backupFile" ]; then echo "Backup file not defined." @@ -22,6 +23,7 @@ echo "Restoring MySQL data from backup." rm -rf "$restoreDir" mkdir -p "$restoreDir" +echo $formatted_date echo "Decompresing backup." gzip --decompress --stdout "$backupFile" \ | mbstream -x --directory="$restoreDir" @@ -32,6 +34,7 @@ mariabackup \ --prepare \ --target-dir="$restoreDir" +echo $formatted_date echo "Stopping service." service mariadb stop if pgrep mariadbd; then pkill -9 mariadbd; fi -- 2.40.1 From 4e193aa116d22d557f403983b8f0cdadf99098f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavi=20Lle=C3=B3?= Date: Thu, 6 Feb 2025 11:41:15 +0000 Subject: [PATCH 2/2] refs #8414 Date format Fix --- roles/db/files/mariabackup/restore-backup.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/db/files/mariabackup/restore-backup.sh b/roles/db/files/mariabackup/restore-backup.sh index e1d458c..0e70424 100644 --- a/roles/db/files/mariabackup/restore-backup.sh +++ b/roles/db/files/mariabackup/restore-backup.sh @@ -6,7 +6,9 @@ myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" . "$myDir/config.sh" backupFile=$1 -formatted_date=$(date -d "$fecha" +"%Y%m%d") +formatted_date() { + date '+%Y-%m-%d %H:%M:%S' +} if [ -z "$backupFile" ]; then echo "Backup file not defined." @@ -23,7 +25,7 @@ echo "Restoring MySQL data from backup." rm -rf "$restoreDir" mkdir -p "$restoreDir" -echo $formatted_date +echo "$(formatted_date)" echo "Decompresing backup." gzip --decompress --stdout "$backupFile" \ | mbstream -x --directory="$restoreDir" @@ -34,7 +36,7 @@ mariabackup \ --prepare \ --target-dir="$restoreDir" -echo $formatted_date +echo "$(formatted_date)" echo "Stopping service." service mariadb stop if pgrep mariadbd; then pkill -9 mariadbd; fi -- 2.40.1