diff --git a/percona-xtradb-cluster-8.0-backup/backup.sh b/percona-xtradb-cluster-8.0-backup/backup.sh index 1b28f7b0..dc4b8709 100755 --- a/percona-xtradb-cluster-8.0-backup/backup.sh +++ b/percona-xtradb-cluster-8.0-backup/backup.sh @@ -84,26 +84,33 @@ function request_streaming() { --group "$PXC_SERVICE" \ --options "$GARBD_OPTS" \ --sst "xtrabackup-v2:$LOCAL_IP:4444/xtrabackup_sst//1" \ - --recv-script="/usr/bin/run_backup.sh" 2>&1 | tee /tmp/garbd.log - - if grep 'Will never receive state. Need to abort' /tmp/garbd.log; then - exit 1 - fi - - if grep 'Donor is no longer in the cluster, interrupting script' /tmp/garbd.log; then - exit 1 - elif grep 'failed: Invalid argument' /tmp/garbd.log; then - exit 1 - fi - - if [ -f '/tmp/backup-is-completed' ]; then - log 'INFO' 'Backup was finished successfully' - exit 0 - fi - - log 'ERROR' 'Backup was finished unsuccessful' - - exit 1 + --extended-exit-codes \ + --wait-for-recv-script-exit \ + --recv-script="/usr/bin/run_backup.sh" + GARBD_EXIT_CODE=$? + + case ${GARBD_EXIT_CODE} in + 0) + log 'INFO' 'Backup was finished successfully' + exit 0 + ;; + 100) + log 'ERROR' 'Backup was unsuccessful: Generic failure' + exit 1 + ;; + 101) + log 'ERROR' 'Backup was unsuccessful: Donor disappeared' + exit 1 + ;; + 102) + log 'ERROR' 'Backup was unsuccessful: SST request failure' + exit 1 + ;; + *) + log 'ERROR' "Backup was unsuccessful: garbd exited with ${GARBD_EXIT_CODE}" + exit 1 + ;; + esac } check_ssl diff --git a/percona-xtradb-cluster-8.0-backup/run_backup.sh b/percona-xtradb-cluster-8.0-backup/run_backup.sh index 792a1e63..2492c0ae 100755 --- a/percona-xtradb-cluster-8.0-backup/run_backup.sh +++ b/percona-xtradb-cluster-8.0-backup/run_backup.sh @@ -88,7 +88,6 @@ backup_volume() { log 'INFO' "Socat(2) returned $?" fi - trap '' 15 stat xtrabackup.stream if (($(stat -c%s xtrabackup.stream) < 5000000)); then log 'ERROR' 'Backup is empty' @@ -123,7 +122,6 @@ backup_s3() { | (grep -v "error: http request failed: Couldn't resolve host name" || exit 1) fi - trap '' 15 aws $AWS_S3_NO_VERIFY_SSL s3 ls s3://$S3_BUCKET/$S3_BUCKET_PATH.md5 md5_size=$(aws $AWS_S3_NO_VERIFY_SSL --output json s3api list-objects --bucket "$S3_BUCKET" --prefix "$S3_BUCKET_PATH.md5" --query 'Contents[0].Size' | sed -e 's/.*"size":\([0-9]*\).*/\1/') if [[ $md5_size =~ "Object does not exist" ]] || ((md5_size < 23000)); then