Skip to content

Commit 09e03a9

Browse files
committed
backup should fail if xbcloud fails
1 parent 738ba17 commit 09e03a9

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

build/backup/backup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function request_streaming() {
6969
--sst "xtrabackup-v2:$LOCAL_IP:4444/xtrabackup_sst//1" \
7070
--extended-exit-codes \
7171
--wait-for-recv-script-exit \
72-
--recv-script="/usr/bin/run_backup.sh"
72+
--recv-script="/opt/percona/backup/run_backup.sh"
7373
GARBD_EXIT_CODE=$?
7474

7575
case ${GARBD_EXIT_CODE} in

build/backup/run_backup.sh

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22

3-
set -o errexit
43
set -o xtrace
4+
set -o errexit
5+
set -o pipefail
56
set -m
67

78
LIB_PATH='/opt/percona/backup/lib/pxc'
@@ -125,15 +126,29 @@ backup_s3() {
125126
fi
126127
vault_store /tmp/${SST_INFO_NAME}
127128

129+
# this xbcloud command will fail with backup is incomplete
130+
# it's expected since we only upload sst_info
131+
set +o pipefail
128132
# shellcheck disable=SC2086
129133
xbstream -C /tmp -c ${SST_INFO_NAME} $XBSTREAM_EXTRA_ARGS \
130-
| xbcloud put --storage=s3 --parallel="$(grep -c processor /proc/cpuinfo)" --md5 $XBCLOUD_ARGS --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME" 2>&1 \
134+
| xbcloud put --storage=s3 \
135+
--md5 \
136+
--parallel="$(grep -c processor /proc/cpuinfo)" \
137+
$XBCLOUD_ARGS \
138+
--s3-bucket="$S3_BUCKET" \
139+
"$S3_BUCKET_PATH.$SST_INFO_NAME" 2>&1 \
131140
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
141+
set -o pipefail
132142

133143
if ((SST_FAILED == 0)); then
134144
# shellcheck disable=SC2086
135145
socat -u "$SOCAT_OPTS" stdio \
136-
| xbcloud put --storage=s3 --parallel="$(grep -c processor /proc/cpuinfo)" --md5 $XBCLOUD_ARGS --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH" 2>&1 \
146+
| xbcloud put --storage=s3 \
147+
--md5 \
148+
--parallel="$(grep -c processor /proc/cpuinfo)" \
149+
$XBCLOUD_ARGS \
150+
--s3-bucket="$S3_BUCKET" \
151+
"$S3_BUCKET_PATH" 2>&1 \
137152
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1) &
138153
wait $!
139154
fi
@@ -170,16 +185,27 @@ backup_azure() {
170185
fi
171186
vault_store /tmp/${SST_INFO_NAME}
172187

188+
# this xbcloud command will fail with backup is incomplete
189+
# it's expected since we only upload sst_info
190+
set +o pipefail
173191
# shellcheck disable=SC2086
174192
xbstream -C /tmp -c ${SST_INFO_NAME} $XBSTREAM_EXTRA_ARGS \
175-
| xbcloud put --storage=azure --parallel="$(grep -c processor /proc/cpuinfo)" $XBCLOUD_ARGS "$BACKUP_PATH.$SST_INFO_NAME" 2>&1 \
193+
| xbcloud put --storage=azure \
194+
--parallel="$(grep -c processor /proc/cpuinfo)" \
195+
$XBCLOUD_ARGS \
196+
"$BACKUP_PATH.$SST_INFO_NAME" 2>&1 \
176197
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
198+
set -o pipefail
177199

178200
if ((SST_FAILED == 0)); then
179201
# shellcheck disable=SC2086
180202
socat -u "$SOCAT_OPTS" stdio \
181-
| xbcloud put --storage=azure --parallel="$(grep -c processor /proc/cpuinfo)" $XBCLOUD_ARGS "$BACKUP_PATH" 2>&1 \
182-
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
203+
| xbcloud put --storage=azure \
204+
--parallel="$(grep -c processor /proc/cpuinfo)" \
205+
$XBCLOUD_ARGS \
206+
"$BACKUP_PATH" 2>&1 \
207+
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1) &
208+
wait $!
183209
fi
184210
}
185211

0 commit comments

Comments
 (0)