github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/oracle-mysql/dataprotection/backup.sh (about) 1 #!/bin/bash 2 set -e 3 set -o pipefail 4 export PATH="$PATH:$DP_DATASAFED_BIN_PATH" 5 export DATASAFED_BACKEND_BASE_PATH="$DP_BACKUP_BASE_PATH" 6 7 # if the script exits with a non-zero exit code, touch a file to indicate that the backup failed, 8 # the sync progress container will check this file and exit if it exists 9 function handle_exit() { 10 exit_code=$? 11 if [ $exit_code -ne 0 ]; then 12 echo "failed with exit code $exit_code" 13 touch "${DP_BACKUP_INFO_FILE}.exit" 14 exit 1 15 fi 16 } 17 trap handle_exit EXIT 18 19 xtrabackup --backup --safe-slave-backup --slave-info --stream=xbstream \ 20 --host=${DP_DB_HOST} --user=${DP_DB_USER} --password=${DP_DB_PASSWORD} --datadir=${DATA_DIR} | datasafed push - "/${DP_BACKUP_NAME}.xbstream" 21 TOTAL_SIZE=$(datasafed stat / | grep TotalSize | awk '{print $2}') 22 echo "{\"totalSize\":\"$TOTAL_SIZE\"}" >"${DP_BACKUP_INFO_FILE}"