From 702b982d6365f1d356d7de43a4b1a1e1d01336ea Mon Sep 17 00:00:00 2001 From: Conor Brady Date: Tue, 6 Feb 2024 14:10:53 -0800 Subject: [PATCH] Cleanup dev deployment pgbackrest archives/backups --- openshift/s3-backup/docker/cleanup_bucket.sh | 14 ++++++++++---- openshift/templates/backup-s3-cleanup-job.yaml | 6 ++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openshift/s3-backup/docker/cleanup_bucket.sh b/openshift/s3-backup/docker/cleanup_bucket.sh index 0bbcee239..f9b4cc156 100755 --- a/openshift/s3-backup/docker/cleanup_bucket.sh +++ b/openshift/s3-backup/docker/cleanup_bucket.sh @@ -6,10 +6,16 @@ # AWS_HOSTNAME=[your aws hostname] AWS_ACCESS_KEY=[your access key] AWS_SECRET_KEY=[your secret key] AWS_BUCKET=[your aws bucket] PG_HOSTNAME=localhost PG_DATABASE=wps ./cleanup_bucket.sh # variable checks -if [ -z ${PG_HOSTNAME+0} ] +if [ -z ${SUFFIX+0} ] then - echo "PG_HOSTNAME not specified" - echo "Specify a postgress hostname" + echo "SUFFIX not specified" + echo "Specify a PR suffix" + exit 1 +fi + +if [ "$SUFFIX" == "prod" ] +then + echo "Please only specify a dev suffix" exit 1 fi @@ -48,7 +54,7 @@ then exit 1 fi -_target_path="s3://${AWS_BUCKET}/backup/${PG_HOSTNAME}_${PG_DATABASE}/" +_target_path="s3://${AWS_BUCKET}/pgbackrest/${SUFFIX}/" echo "Cleaning up ${_target_path}" AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY}" AWS_SECRET_ACCESS_KEY="${AWS_SECRET_KEY}" aws --endpoint="https://${AWS_HOSTNAME}" s3 rm --recursive "${_target_path}" diff --git a/openshift/templates/backup-s3-cleanup-job.yaml b/openshift/templates/backup-s3-cleanup-job.yaml index 0f11d7270..1ac977e68 100644 --- a/openshift/templates/backup-s3-cleanup-job.yaml +++ b/openshift/templates/backup-s3-cleanup-job.yaml @@ -60,9 +60,7 @@ objects: secretKeyRef: name: ${GLOBAL_NAME} key: object-store-bucket - - name: PG_DATABASE - value: wps - - name: PG_HOSTNAME - value: ${CLUSTER_NAME}-leader + - name: SUFFIX + value: ${SUFFIX} command: ["bash", "cleanup_bucket.sh"] restartPolicy: OnFailure