Skip to content

Commit 2c71782

Browse files
authored
STAC-25087 fail restore on missing StackPacks backup; drop S3 prefix on local-bucket download (#31)
1 parent 24cf6b7 commit 2c71782

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

internal/scripts/scripts/restore-settings-backup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ else
7070
echo "=== Checking for StackPacks backup \"${STACKPACKS_FILE}\" in bucket \"${BACKUP_CONFIGURATION_LOCAL_BUCKET}\"..."
7171
setup_aws_credentials
7272

73-
if download_from_s3 "${BACKUP_CONFIGURATION_LOCAL_BUCKET}" "${BACKUP_CONFIGURATION_S3_PREFIX}${BACKUP_CONFIGURATION_STACKPACKS_DIR}" "${TMP_DIR}" "${STACKPACKS_FILE}"; then
73+
if download_from_s3 "${BACKUP_CONFIGURATION_LOCAL_BUCKET}" "${BACKUP_CONFIGURATION_STACKPACKS_DIR}" "${TMP_DIR}" "${STACKPACKS_FILE}"; then
7474
STACKPACKS_RESTORE_FILE="${TMP_DIR}/${STACKPACKS_FILE}"
7575
elif [ "${BACKUP_CONFIGURATION_UPLOAD_REMOTE}" == "true" ]; then
7676
echo "=== StackPacks backup not found in kubernetes settings storage, trying main backups storage..."
@@ -80,8 +80,8 @@ else
8080
fi
8181

8282
if [ -z "${STACKPACKS_RESTORE_FILE}" ] || [ ! -f "${STACKPACKS_RESTORE_FILE}" ]; then
83-
echo "=== WARNING: StackPacks backup \"${STACKPACKS_FILE}\" not found, skipping StackPacks restore"
84-
exit 0
83+
echo "=== ERROR: StackPacks backup \"${STACKPACKS_FILE}\" not found"
84+
exit 1
8585
fi
8686

8787
echo "=== Restoring StackPacks from \"${STACKPACKS_FILE}\"..."

internal/scripts/scripts/restore-stackgraph-backup.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ else
2525
echo "=== Checking for StackPacks backup \"${STACKPACKS_FILE}\" in bucket \"${BACKUP_STACKGRAPH_BUCKET_NAME}\"..."
2626

2727
# Check if stackpacks backup exists in S3
28-
if sts-toolbox aws s3 ls --endpoint "http://${MINIO_ENDPOINT}" --region minio --bucket "${BACKUP_STACKGRAPH_BUCKET_NAME}" --prefix "${BACKUP_STACKGRAPH_S3_PREFIX}${BACKUP_STACKGRAPH_STACKPACKS_DIR}${STACKPACKS_FILE}" 2>/dev/null | grep -q "${STACKPACKS_FILE}"; then
29-
echo "=== Downloading StackPacks backup..."
30-
sts-toolbox aws s3 cp --endpoint "http://${MINIO_ENDPOINT}" --region minio "s3://${BACKUP_STACKGRAPH_BUCKET_NAME}/${BACKUP_STACKGRAPH_S3_PREFIX}${BACKUP_STACKGRAPH_STACKPACKS_DIR}${STACKPACKS_FILE}" "${TMP_DIR}/${STACKPACKS_FILE}"
31-
32-
echo "=== Restoring StackPacks from \"${STACKPACKS_FILE}\"..."
33-
/opt/docker/bin/stack-packs-backup -Dlogback.configurationFile=/opt/docker/etc_log/logback.xml -restore "${TMP_DIR}/${STACKPACKS_FILE}"
34-
echo "=== StackPacks restore complete"
35-
else
36-
echo "=== WARNING: StackPacks backup \"${STACKPACKS_FILE}\" not found in S3, skipping StackPacks restore"
28+
if ! sts-toolbox aws s3 ls --endpoint "http://${MINIO_ENDPOINT}" --region minio --bucket "${BACKUP_STACKGRAPH_BUCKET_NAME}" --prefix "${BACKUP_STACKGRAPH_S3_PREFIX}${BACKUP_STACKGRAPH_STACKPACKS_DIR}${STACKPACKS_FILE}" 2>/dev/null | grep -q "${STACKPACKS_FILE}"; then
29+
echo "=== ERROR: StackPacks backup \"${STACKPACKS_FILE}\" not found in S3"
30+
exit 1
3731
fi
32+
33+
echo "=== Downloading StackPacks backup..."
34+
sts-toolbox aws s3 cp --endpoint "http://${MINIO_ENDPOINT}" --region minio "s3://${BACKUP_STACKGRAPH_BUCKET_NAME}/${BACKUP_STACKGRAPH_S3_PREFIX}${BACKUP_STACKGRAPH_STACKPACKS_DIR}${STACKPACKS_FILE}" "${TMP_DIR}/${STACKPACKS_FILE}"
35+
36+
echo "=== Restoring StackPacks from \"${STACKPACKS_FILE}\"..."
37+
/opt/docker/bin/stack-packs-backup -Dlogback.configurationFile=/opt/docker/etc_log/logback.xml -restore "${TMP_DIR}/${STACKPACKS_FILE}"
38+
echo "=== StackPacks restore complete"
3839
fi
3940
echo "==="

0 commit comments

Comments
 (0)