|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -set -o errexit |
4 | 3 | set -o xtrace |
| 4 | +set -o errexit |
| 5 | +set -o pipefail |
5 | 6 | set -m |
6 | 7 |
|
7 | 8 | LIB_PATH='/opt/percona/backup/lib/pxc' |
@@ -125,15 +126,29 @@ backup_s3() { |
125 | 126 | fi |
126 | 127 | vault_store /tmp/${SST_INFO_NAME} |
127 | 128 |
|
| 129 | + # this xbcloud command will fail with backup is incomplete |
| 130 | + # it's expected since we only upload sst_info |
| 131 | + set +o pipefail |
128 | 132 | # shellcheck disable=SC2086 |
129 | 133 | 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 \ |
131 | 140 | | (grep -v "error: http request failed: Couldn't resolve host name" || exit 1) |
| 141 | + set -o pipefail |
132 | 142 |
|
133 | 143 | if ((SST_FAILED == 0)); then |
134 | 144 | # shellcheck disable=SC2086 |
135 | 145 | 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 \ |
137 | 152 | | (grep -v "error: http request failed: Couldn't resolve host name" || exit 1) & |
138 | 153 | wait $! |
139 | 154 | fi |
@@ -170,16 +185,27 @@ backup_azure() { |
170 | 185 | fi |
171 | 186 | vault_store /tmp/${SST_INFO_NAME} |
172 | 187 |
|
| 188 | + # this xbcloud command will fail with backup is incomplete |
| 189 | + # it's expected since we only upload sst_info |
| 190 | + set +o pipefail |
173 | 191 | # shellcheck disable=SC2086 |
174 | 192 | 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 \ |
176 | 197 | | (grep -v "error: http request failed: Couldn't resolve host name" || exit 1) |
| 198 | + set -o pipefail |
177 | 199 |
|
178 | 200 | if ((SST_FAILED == 0)); then |
179 | 201 | # shellcheck disable=SC2086 |
180 | 202 | 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 $! |
183 | 209 | fi |
184 | 210 | } |
185 | 211 |
|
|
0 commit comments