diff --git a/.dir-locals.el b/.dir-locals.el deleted file mode 100644 index 3b14d0c..0000000 --- a/.dir-locals.el +++ /dev/null @@ -1,4 +0,0 @@ -;;; Directory Local Variables -;;; For more information see (info "(emacs) Directory Variables") - -((sh-mode . ((sh-basic-offset . 2)))) diff --git a/.github/workflows/build-and-push-images.yml b/.github/workflows/build-and-push-images.yml deleted file mode 100644 index 6b89df2..0000000 --- a/.github/workflows/build-and-push-images.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: build and push images - -on: - push: - branches: ['master'] - -jobs: - build-and-push-image: - runs-on: ubuntu-latest - - strategy: - matrix: - include: - - { postgres: 12, alpine: '3.12' } - - { postgres: 13, alpine: '3.14' } - - { postgres: 14, alpine: '3.16' } - - { postgres: 15, alpine: '3.17' } - - { postgres: 16, alpine: '3.19' } - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: ${{ github.repository }}:${{ matrix.postgres }} - build-args: | - ALPINE_VERSION=${{ matrix.alpine }} - platforms: | - linux/amd64 - linux/arm64 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3bf780b..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea -.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 16915d7..0600430 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -ARG ALPINE_VERSION -FROM alpine:${ALPINE_VERSION} +ARG POSTGRES_VERSION +FROM postgres:${POSTGRES_VERSION}-alpine ARG TARGETARCH ADD src/install.sh install.sh diff --git a/LICENSE.txt b/LICENSE.txt index d1988db..cf50b4a 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Johannes Schickling +Copyright (c) 2017 Johannes Schickling, Elliott Shugerman, and Miha Rekar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 67e2f99..cd6a97c 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,23 @@ # Introduction -This project provides Docker images to periodically back up a PostgreSQL database to AWS S3, and to restore from the backup as needed. + +This is a blatant fork of https://github.com/eeshugerman/postgres-backup-s3 which was itself a fork and re-structuring of @schickling's [postgres-backup-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-backup-s3) and [postgres-restore-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-restore-s3). + +It was archived and I still relied on it. Plus I needed PG 18. + +# Building the image + +Obviously replace `miharekar` with your dockerhub username and `18.0` with the desired PostgreSQL version. + +``` +❯ docker build -t miharekar/postgres-backup-s3:18.0 --build-arg POSTGRES_VERSION='18.0' . && docker push miharekar/postgres-backup-s3:18.0 +``` # Usage ## Backup ```yaml services: - postgres: - image: postgres:16 - environment: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - backup: - image: eeshugerman/postgres-backup-s3:16 + image: miharekar/postgres-backup-s3:18.0 environment: SCHEDULE: '@weekly' # optional BACKUP_KEEP_DAYS: 7 # optional @@ -28,7 +33,6 @@ services: POSTGRES_PASSWORD: password ``` -- Images are tagged by the major PostgreSQL version supported: `12`, `13`, `14`, `15` or `16`. - The `SCHEDULE` variable determines backup frequency. See go-cron schedules documentation [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). Omit to run the backup immediately and then exit. - If `PASSPHRASE` is provided, the backup will be encrypted using GPG. - Run `docker exec sh backup.sh` to trigger a backup ad-hoc. @@ -52,30 +56,16 @@ docker exec sh restore.sh docker exec sh restore.sh ``` -# Development -## Build the image locally -`ALPINE_VERSION` determines Postgres version compatibility. See [`build-and-push-images.yml`](.github/workflows/build-and-push-images.yml) for the latest mapping. -```sh -DOCKER_BUILDKIT=1 docker build --build-arg ALPINE_VERSION=3.14 . -``` -## Run a simple test environment with Docker Compose -```sh -cp template.env .env -# fill out your secrets/params in .env -docker compose up -d -``` - # Acknowledgements -This project is a fork and re-structuring of @schickling's [postgres-backup-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-backup-s3) and [postgres-restore-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-restore-s3). -## Fork goals -These changes would have been difficult or impossible merge into @schickling's repo or similarly-structured forks. +As mentioned above, this project is a blatant fork of https://github.com/eeshugerman/postgres-backup-s3 + +As is the following text documenting the changes from the @schickling's [postgres-backup-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-backup-s3): + - dedicated repository - automated builds - support multiple PostgreSQL versions - backup and restore with one image - -## Other changes and features - some environment variables renamed or removed - uses `pg_dump`'s `custom` format (see [docs](https://www.postgresql.org/docs/10/app-pgdump.html)) - drop and re-create all database objects on restore @@ -85,3 +75,5 @@ These changes would have been difficult or impossible merge into @schickling's r - support encrypted (password-protected) backups - support for restoring from a specific backup by timestamp - support for auto-removal of old backups + +What's new in my fork is solely support for later versions of PostgreSQL. diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 16ac481..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# this file is here to facilitate development/testing -# $ docker compose up -d --build --force-recreate - -services: - postgres: - image: postgres:14 - environment: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - - backup: - build: - context: . - args: - ALPINE_VERSION: '3.16' - environment: - SCHEDULE: '@weekly' # optional - BACKUP_KEEP_DAYS: 7 # optional - PASSPHRASE: passphrase # optional - S3_REGION: - S3_ACCESS_KEY_ID: - S3_SECRET_ACCESS_KEY: - S3_BUCKET: - S3_PREFIX: backup - POSTGRES_HOST: postgres - POSTGRES_DATABASE: postgres - POSTGRES_USER: user - POSTGRES_PASSWORD: password diff --git a/template.env b/template.env deleted file mode 100644 index e0b5c24..0000000 --- a/template.env +++ /dev/null @@ -1,4 +0,0 @@ -S3_REGION="" -S3_ACCESS_KEY_ID="" -S3_SECRET_ACCESS_KEY="" -S3_BUCKET=""