Merge pull request 'refs #8414 - restore-backup.sh script - Add formatted_date to log start and end of operations' (!63) from 8414_Refactor_MariaDB_rol-Split into main

Reviewed-on: #63
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
Xavi Lleó 2025-02-07 14:16:33 +00:00
commit c8b81ea9a5
1 changed files with 5 additions and 0 deletions

View File

@ -6,6 +6,9 @@ myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$myDir/config.sh"
backupFile=$1
formatted_date() {
date '+%Y-%m-%d %H:%M:%S'
}
if [ -z "$backupFile" ]; then
echo "Backup file not defined."
@ -22,6 +25,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 +36,7 @@ mariabackup \
--prepare \
--target-dir="$restoreDir"
echo "$(formatted_date)"
echo "Stopping service."
service mariadb stop
if pgrep mariadbd; then pkill -9 mariadbd; fi