Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8SPXC-1372: handle SKIP_FAILED_BACKUP_CLEANUP env var #1127

Closed
wants to merge 4 commits into from
Closed
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
6 changes: 6 additions & 0 deletions percona-xtradb-cluster-5.7-backup/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ backup_s3() {
{ set +x; } 2>/dev/null
s3_add_bucket_dest
set -x
# The previous failed backup must be deleted before making a new attempt.
# xbcloud does not support overwriting backups and will fail with an error:
# https://github.com/percona/percona-xtrabackup/blob/a99dce574690616b296b8a8cc7c590deb937f7d3/storage/innobase/xtrabackup/src/xbcloud/xbcloud.cc#L956
is_object_exist "$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME" || xbcloud delete ${INSECURE_ARG} $XBCLOUD_EXTRA_ARGS --storage=s3 --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME"
is_object_exist "$S3_BUCKET" "$S3_BUCKET_PATH" || xbcloud delete ${INSECURE_ARG} $XBCLOUD_EXTRA_ARGS --storage=s3 --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH"
request_streaming
Expand Down Expand Up @@ -219,6 +222,9 @@ backup_azure() {

echo "[INFO] Backup to $ENDPOINT/$AZURE_CONTAINER_NAME/$BACKUP_PATH"

# The previous failed backup must be deleted before making a new attempt.
# xbcloud does not support overwriting backups and will fail with an error:
# https://github.com/percona/percona-xtrabackup/blob/a99dce574690616b296b8a8cc7c590deb937f7d3/storage/innobase/xtrabackup/src/xbcloud/xbcloud.cc#L956
is_object_exist_azure "$BACKUP_PATH.$SST_INFO_NAME/" || xbcloud delete ${INSECURE_ARG} $XBCLOUD_EXTRA_ARGS --storage=azure "$BACKUP_PATH.$SST_INFO_NAME"
is_object_exist_azure "$BACKUP_PATH/" || xbcloud delete ${INSECURE_ARG} $XBCLOUD_EXTRA_ARGS --storage=azure "$BACKUP_PATH"
request_streaming
Expand Down
3 changes: 3 additions & 0 deletions percona-xtradb-cluster-8.0-backup/lib/pxc/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ log() {
clean_backup_s3() {
s3_add_bucket_dest

# The previous failed backup must be deleted before making a new attempt.
# xbcloud does not support overwriting backups and will fail with an error:
# https://github.com/percona/percona-xtrabackup/blob/a99dce574690616b296b8a8cc7c590deb937f7d3/storage/innobase/xtrabackup/src/xbcloud/xbcloud.cc#L956
is_object_exist "$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME" || xbcloud delete ${XBCLOUD_ARGS} --storage=s3 --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME"
is_object_exist "$S3_BUCKET" "$S3_BUCKET_PATH/" || xbcloud delete ${XBCLOUD_ARGS} --storage=s3 --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH"
}
Expand Down
13 changes: 8 additions & 5 deletions percona-xtradb-cluster-8.0-backup/run_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ check_ssl() {
FIRST_RECEIVED=0
SST_FAILED=0
handle_sigterm() {
if (($FIRST_RECEIVED == 0)); then
if ((FIRST_RECEIVED == 0)); then
pid_s=$(ps -C socat -o pid= || true)
if [ -n "${pid_s}" ]; then
log 'ERROR' 'SST request failed'
Expand Down Expand Up @@ -78,7 +78,7 @@ backup_volume() {
echo "[IINFO] Socat(1) returned $?"
vault_store $BACKUP_DIR/${SST_INFO_NAME}

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
socat -u "$SOCAT_OPTS" stdio >xtrabackup.stream
if [[ $? -ne 0 ]]; then
log 'ERROR' 'Socat(2) failed'
Expand Down Expand Up @@ -117,7 +117,7 @@ backup_s3() {
| xbcloud put --parallel="$(grep -c processor /proc/cpuinfo)" --storage=s3 --md5 $XBCLOUD_ARGS --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
socat -u "$SOCAT_OPTS" stdio \
| xbcloud put --storage=s3 --parallel="$(grep -c processor /proc/cpuinfo)" --md5 $XBCLOUD_ARGS --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
Expand All @@ -138,6 +138,9 @@ backup_azure() {

log 'INFO' "Backup to $ENDPOINT/$AZURE_CONTAINER_NAME/$BACKUP_PATH"

# The previous failed backup must be deleted before making a new attempt.
# xbcloud does not support overwriting backups and will fail with an error:
# https://github.com/percona/percona-xtrabackup/blob/a99dce574690616b296b8a8cc7c590deb937f7d3/storage/innobase/xtrabackup/src/xbcloud/xbcloud.cc#L956
is_object_exist_azure "$BACKUP_PATH.$SST_INFO_NAME/" || xbcloud delete $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH.$SST_INFO_NAME"
is_object_exist_azure "$BACKUP_PATH/" || xbcloud delete $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH"

Expand All @@ -157,7 +160,7 @@ backup_azure() {
| xbcloud put --parallel="$(grep -c processor /proc/cpuinfo)" $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH.$SST_INFO_NAME" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
socat -u "$SOCAT_OPTS" stdio \
| xbcloud put --parallel="$(grep -c processor /proc/cpuinfo)" $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
Expand All @@ -176,7 +179,7 @@ else
backup_volume
fi

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
touch /tmp/backup-is-completed
fi

Expand Down
3 changes: 3 additions & 0 deletions percona-xtradb-cluster-8.4-backup/lib/pxc/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ log() {
clean_backup_s3() {
s3_add_bucket_dest

# The previous failed backup must be deleted before making a new attempt.
# xbcloud does not support overwriting backups and will fail with an error:
# https://github.com/percona/percona-xtrabackup/blob/a99dce574690616b296b8a8cc7c590deb937f7d3/storage/innobase/xtrabackup/src/xbcloud/xbcloud.cc#L956
is_object_exist "$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME" || xbcloud delete ${XBCLOUD_ARGS} --storage=s3 --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME"
is_object_exist "$S3_BUCKET" "$S3_BUCKET_PATH/" || xbcloud delete ${XBCLOUD_ARGS} --storage=s3 --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH"
}
Expand Down
13 changes: 8 additions & 5 deletions percona-xtradb-cluster-8.4-backup/run_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ check_ssl() {
FIRST_RECEIVED=0
SST_FAILED=0
handle_sigterm() {
if (($FIRST_RECEIVED == 0)); then
if ((FIRST_RECEIVED == 0)); then
pid_s=$(ps -C socat -o pid= || true)
if [ -n "${pid_s}" ]; then
log 'ERROR' 'SST request failed'
Expand Down Expand Up @@ -78,7 +78,7 @@ backup_volume() {
echo "[IINFO] Socat(1) returned $?"
vault_store $BACKUP_DIR/${SST_INFO_NAME}

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
socat -u "$SOCAT_OPTS" stdio >xtrabackup.stream
if [[ $? -ne 0 ]]; then
log 'ERROR' 'Socat(2) failed'
Expand Down Expand Up @@ -117,7 +117,7 @@ backup_s3() {
| xbcloud put --parallel="$(grep -c processor /proc/cpuinfo)" --storage=s3 --md5 $XBCLOUD_ARGS --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH.$SST_INFO_NAME" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
socat -u "$SOCAT_OPTS" stdio \
| xbcloud put --storage=s3 --parallel="$(grep -c processor /proc/cpuinfo)" --md5 $XBCLOUD_ARGS --s3-bucket="$S3_BUCKET" "$S3_BUCKET_PATH" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
Expand All @@ -138,6 +138,9 @@ backup_azure() {

log 'INFO' "Backup to $ENDPOINT/$AZURE_CONTAINER_NAME/$BACKUP_PATH"

# The previous failed backup must be deleted before making a new attempt.
# xbcloud does not support overwriting backups and will fail with an error:
# https://github.com/percona/percona-xtrabackup/blob/a99dce574690616b296b8a8cc7c590deb937f7d3/storage/innobase/xtrabackup/src/xbcloud/xbcloud.cc#L956
is_object_exist_azure "$BACKUP_PATH.$SST_INFO_NAME/" || xbcloud delete $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH.$SST_INFO_NAME"
is_object_exist_azure "$BACKUP_PATH/" || xbcloud delete $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH"

Expand All @@ -157,7 +160,7 @@ backup_azure() {
| xbcloud put --parallel="$(grep -c processor /proc/cpuinfo)" $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH.$SST_INFO_NAME" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
socat -u "$SOCAT_OPTS" stdio \
| xbcloud put --parallel="$(grep -c processor /proc/cpuinfo)" $XBCLOUD_ARGS --storage=azure "$BACKUP_PATH" 2>&1 \
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
Expand All @@ -176,7 +179,7 @@ else
backup_volume
fi

if (($SST_FAILED == 0)); then
if ((SST_FAILED == 0)); then
touch /tmp/backup-is-completed
fi

Expand Down
Loading