Skip to content

Pg16 r2 #6

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM alpine:3.15
FROM alpine:3.19

RUN apk update \
&& apk --no-cache add dumb-init postgresql-client curl aws-cli
&& apk --no-cache add dumb-init postgresql16-client curl aws-cli

RUN curl -L https://github.com/odise/go-cron/releases/download/v0.0.7/go-cron-linux.gz | zcat > /usr/local/bin/go-cron && chmod +x /usr/local/bin/go-cron

COPY entrypoint.sh .
COPY backup.sh .

ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["sh", "entrypoint.sh"]
CMD ["sh", "entrypoint.sh"]
5 changes: 3 additions & 2 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ case "${PG_BACKUP_ACTION:-dump}" in
# TODO: check if database is fresh
echo "Snapshotting $POSTGRES_DB database"
pg_dump -Fc $POSTGRES_HOST_OPTS $POSTGRES_DB > dump.backup
aws configure set default.s3.multipart_chunksize 16MB
aws configure set default.s3.multipart_chunksize 64MB

if [ "${PRIVATE_BACKUP}" == "true" ] || [ "${PRIVATE_BACKUP}" == "1" ]; then
echo "Rotating old snapshot"
Expand All @@ -66,7 +66,7 @@ case "${PG_BACKUP_ACTION:-dump}" in
cat dump.backup | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PATH/$S3_FILENAME.backup --acl private || exit 2
else
echo "Rotating old snapshot"
aws $AWS_ARGS s3 cp s3://$S3_BUCKET/$S3_PATH/$S3_FILENAME.backup s3://$S3_BUCKET/$S3_PATH/$S3_FILENAME.old.backup --acl public-read || true
aws $AWS_ARGS s3 cp s3://$S3_BUCKET/$S3_PATH/$S3_FILENAME.backup s3://$S3_BUCKET/$S3_PATH/$S3_FILENAME.old.backup --metadata-directive REPLACE --acl public-read || true

echo "Uploading fresh public snapshot to $S3_BUCKET/$S3_PATH/$S3_FILENAME"
cat dump.backup | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PATH/$S3_FILENAME.backup --acl public-read || exit 2
Expand All @@ -93,3 +93,4 @@ case "${PG_BACKUP_ACTION:-dump}" in
pg_restore -v -d $POSTGRES_DB $POSTGRES_HOST_OPTS dump.backup
;;
esac

13 changes: 13 additions & 0 deletions boto.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Credentials]
gs_access_key_id=replace_gs_access_key_id
gs_secret_access_key=replace_gs_secret_access_key

[Boto]

[GoogleCompute]

[GSUtil]
content_language = en
default_api_version = 2

[OAuth2]
Loading