Skip to content

Commit

Permalink
Merge pull request #19 from Obmondo/v1.0.4
Browse files Browse the repository at this point in the history
add pg_dumpall
  • Loading branch information
ashish1099 authored Jul 19, 2024
2 parents d84adbb + f3e6ce5 commit 9b512d1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/postgres-logical-backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Logical backup

on:
push:
branches: [ "*" ]
paths: 'postgres-logical-backup/**'
tags: [ "v*" ]

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Generate container metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/obmondo/postgres-logical-backup
tags: |
type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }}
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
type=ref,event=tag
flavor: |
latest=false
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & push container image
id: docker_build
uses: docker/build-push-action@v2
with:
file: "./postgres-logical-backup/Dockerfile"
context: .
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ COPY ./* ./

ENV PG_DIR=/usr/lib/postgresql


ENTRYPOINT ["/dump.sh"]
6 changes: 3 additions & 3 deletions logical-backup/dump.sh → postgres-logical-backup/dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function estimate_size {
function dump {
echo "Taking dump of ${PGDATABASE} from ${PGHOST}"
# settings are taken from the environment
"$PG_BIN"/pg_dump
"$PG_BIN"/pg_dumpall --exclude-database='postgres'
}

function compress {
Expand All @@ -42,7 +42,7 @@ function aws_delete_objects {
[[ ! -z "${LOGICAL_BACKUP_S3_ENDPOINT}" ]] && args+=("--endpoint-url=${LOGICAL_BACKUP_S3_ENDPOINT}")
[[ ! -z "${LOGICAL_BACKUP_S3_REGION}" ]] && args+=("--region=${LOGICAL_BACKUP_S3_REGION}")

aws s3api delete-objects "${args[@]}" --delete Objects=["$(printf {Key=%q}, "$@")"],Quiet=true
aws s3api delete-objects "${args[@]}" --delete Objects=["$(printf \{Key=%q\}, "$@")"],Quiet=true
}
export -f aws_delete_objects

Expand Down Expand Up @@ -129,4 +129,4 @@ else
[[ ${PIPESTATUS[0]} != 0 || ${PIPESTATUS[1]} != 0 || ${PIPESTATUS[2]} != 0 ]] && (( ERRORCOUNT += 1 ))
set +x
exit $ERRORCOUNT
fi
fi

0 comments on commit 9b512d1

Please sign in to comment.