Skip to content

Commit

Permalink
Cleanup dev deployment pgbackrest archives/backups
Browse files Browse the repository at this point in the history
  • Loading branch information
conbrad committed Feb 6, 2024
1 parent 92a416a commit 702b982
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 10 additions & 4 deletions openshift/s3-backup/docker/cleanup_bucket.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}"
Expand Down
6 changes: 2 additions & 4 deletions openshift/templates/backup-s3-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 702b982

Please sign in to comment.