Skip to content

Commit 9d90e37

Browse files
authored
Merge pull request #225 from alwynpan/bugfix/#199
#199 Report error when move the backup file to S3 or Blob fails
2 parents 68174c0 + 12484bb commit 9d90e37

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ RUN source /assets/functions/00-container && \
4747
redis \
4848
sqlite \
4949
xz \
50+
zip \
5051
zstd \
5152
&& \
5253
\

install/assets/functions/10-db-backup

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ backup_couch() {
137137
check_exit_code $target
138138
generate_checksum
139139
move_dbbackup
140+
check_exit_code "move backup file"
140141
post_dbbackup ${DB_NAME}
141142
}
142143

@@ -167,6 +168,7 @@ backup_influx() {
167168
ltarget=influx_${db}_${DB_HOST#*//}
168169
generate_checksum
169170
move_dbbackup
171+
check_exit_code "move backup file"
170172
post_dbbackup $db
171173
done
172174
;;
@@ -187,6 +189,7 @@ backup_influx() {
187189
ltarget=influx2_${db}_${DB_HOST#*//}
188190
generate_checksum
189191
move_dbbackup
192+
check_exit_code "move backup file"
190193
post_dbbackup $db
191194
done
192195
;;
@@ -216,6 +219,7 @@ backup_mongo() {
216219
check_exit_code $target
217220
generate_checksum
218221
move_dbbackup
222+
check_exit_code "move backup file"
219223
post_dbbackup "${DB_NAME}"
220224
}
221225

@@ -231,6 +235,7 @@ backup_mssql() {
231235
check_exit_code $target
232236
generate_checksum
233237
move_dbbackup
238+
check_exit_code "move backup file"
234239
post_dbbackup $DB_NAME
235240
}
236241

@@ -271,6 +276,7 @@ backup_mysql() {
271276
check_exit_code $target
272277
generate_checksum
273278
move_dbbackup
279+
check_exit_code "move backup file"
274280
post_dbbackup $db
275281
done
276282
else
@@ -286,6 +292,7 @@ backup_mysql() {
286292
check_exit_code $target
287293
generate_checksum
288294
move_dbbackup
295+
check_exit_code "move backup file"
289296
post_dbbackup all
290297
fi
291298
}
@@ -322,6 +329,7 @@ backup_pgsql() {
322329
check_exit_code $target
323330
generate_checksum
324331
move_dbbackup
332+
check_exit_code "move backup file"
325333
post_dbbackup $db
326334
done
327335
else
@@ -345,6 +353,7 @@ backup_pgsql() {
345353
check_exit_code $target
346354
generate_checksum
347355
move_dbbackup
356+
check_exit_code "move backup file"
348357
post_dbbackup all
349358
fi
350359
}
@@ -376,6 +385,7 @@ backup_redis() {
376385
check_exit_code $target
377386
generate_checksum
378387
move_dbbackup
388+
check_exit_code "move backup file"
379389
post_dbbackup all
380390
}
381391

@@ -394,6 +404,7 @@ backup_sqlite3() {
394404
cat "${TEMP_LOCATION}"/backup.sqlite3 | ${dir_compress_cmd} > "${TEMP_LOCATION}/${target}"
395405
generate_checksum
396406
move_dbbackup
407+
check_exit_code "move backup file"
397408
post_dbbackup $db
398409
}
399410

@@ -711,6 +722,7 @@ move_dbbackup() {
711722
[[ ( -n "${S3_HOST}" ) ]] && PARAM_AWS_ENDPOINT_URL=" --endpoint-url ${S3_PROTOCOL}://${S3_HOST}"
712723

713724
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 cp ${TEMP_LOCATION}/${target} s3://${S3_BUCKET}/${S3_PATH}/${target} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
725+
exit_code=$?
714726
if var_true "${ENABLE_CHECKSUM}" ; then
715727
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 cp ${TEMP_LOCATION}/*.${checksum_extension} s3://${S3_BUCKET}/${S3_PATH}/ ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
716728
fi
@@ -726,6 +738,7 @@ move_dbbackup() {
726738
mv "${TEMP_LOCATION}"/"${target}" "${DB_DUMP_TARGET}"/"${target}"
727739

728740
silent blobxfer upload --mode file --remote-path ${BLOBXFER_REMOTE_PATH} --local-path ${DB_DUMP_TARGET}
741+
exit_code=$?
729742

730743
rm -rf "${TEMP_LOCATION}"/*."${checksum_extension}"
731744
rm -rf "${TEMP_LOCATION}"/"${target}"

0 commit comments

Comments
 (0)