Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions percona-xtradb-cluster-8.0-backup/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions percona-xtradb-cluster-8.0-backup/run_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
Loading