Skip to content

Commit

Permalink
add script backup
Browse files Browse the repository at this point in the history
  • Loading branch information
topahadzi committed Sep 12, 2023
1 parent 90d4405 commit 610cefd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ RUN curl -sSLo /tmp/linkerd-await https://github.com/linkerd/linkerd-await/relea
chmod 755 /tmp/linkerd-await

FROM alpine:3.18
WORKDIR /app
ARG RCLONE_VER=v1.64.0
RUN apk update && apk add postgresql
COPY --from=build /app/rclone-${RCLONE_VER}-linux-amd64/rclone /usr/local/bin/
COPY --from=build /tmp/linkerd-await /usr/local/bin/
COPY backup.sh /app/backup.sh
ENTRYPOINT ["linkerd-await", "--shutdown", "--"]
CMD ["/app/backup.sh"]
28 changes: 28 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
set -e

rclone_s3() {
rclone \
--s3-endpoint "$S3_ENDPOINT" \
--s3-region "$S3_REGION" \
--s3-access-key-id "$S3_ACCESS_KEY_ID" \
--s3-secret-access-key "$S3_SECRET_ACCESS_KEY" \
--s3-no-head \
--s3-no-check-bucket \
--s3-disable-http2 \
--s3-disable-checksum \
--s3-chunk-size 1G \
--s3-upload-concurrency 16 \
--ignore-times \
--fast-list \
--links \
--checkers=32 \
--transfers=128 \
--stats-log-level NOTICE \
--stats=10s \
$@
}
TIMESTAMP=$(date '+%Y-%-m-%d')
remote_path=":s3:backup-vira-sh/$APP_NAME/$DB_INSTANCE_NAME/$DB_NAME/$TIMESTAMP"

PGPASSWORD=$DB_PASSWORD pg_dump -h $DB_HOST --no-publications --no-owner -U $DB_USERNAME -O -x -Fc $DB_NAME | rclone_s3 rcat "$remote_path"

0 comments on commit 610cefd

Please sign in to comment.