BCDevOps / backup-container

A simple container for a simple backup strategy.
Apache License 2.0
42 stars 56 forks source link

Add a dockerfile for postgres 12 #62

Closed ikethecoder closed 4 years ago

ikethecoder commented 4 years ago

We are looking to deploy Patroni based on the Spilo docker image and it is running Postgres 12. There was an error around version incompatibility with pg_dump between Postgres 10 and 12, so want to have a new Dockerfile that supports Postgres 12. I have also created a helm chart for deploying this solution so would like to reference it in the README.

ikethecoder commented 4 years ago

I'm fine with replacing the Dockerfile. I've verified it works with a v12 postgres, but is any regression testing needed to make sure it still works with previous versions? Do you have earlier versions around to test the new image?

WadeBarnes commented 4 years ago

I have some Postgres 10 images I can test it on, and I think I have some v9.5 ones (perhaps) too. I'm not hugely concerned whether or not it works other than being able to indicate whether or not it does. We're maintaining releases (https://github.com/BCDevOps/backup-container/releases) so users can select and build off the release that works with their version of Postgres. When using V10 in the backup container, it worked with v9.x databases. The versions did not need to match, the backup container just needed to be using a newer or equal version.

ikethecoder commented 4 years ago

Great, I've made the updates.

WadeBarnes commented 4 years ago

Assigned to myself for testing.

WadeBarnes commented 4 years ago

@ikethecoder, Any particular reason you're fixing the image version using the tag rather than letting a new build get the latest image?

ikethecoder commented 4 years ago

Only to provide some predictability to the build

WadeBarnes commented 4 years ago

Successfully tested backup and verification on an existing PostgreSQL v9.5.x database.

sh-4.2$ postgres --version
postgres (PostgreSQL) 12.1

sh-4.2$ ./backup.sh -s

Starting backup process ...
Reading backup config from backup.conf ...
Making backup directory /backups/weekly/2020-10-04/ ...

...

Backing up 'postgres:5432/appdb' to '/backups/weekly/2020-10-04/postgres-appdb_2020-10-04_09-11-24.sql.gz.in_progress' ...
Successfully backed up postgres:5432/appdb.
Backup written to /backups/weekly/2020-10-04/postgres-appdb_2020-10-04_09-11-24.sql.gz.
Database Size: 18 MB
Backup Size: 1.5M

Elapsed time: 0h:0m:3s - Status Code: 0

Pruning postgres-appdb backups from /backups/weekly ...
removed '/backups/weekly/2020-09-13/postgres-appdb_2020-09-13_01-00-00.sql.gz'

...

sh-4.2$ ./backup.sh -s -v all

Verifying backup ...

Settings:
- Database: postgres:5432/appdb
- Backup file: /backups/weekly/2020-10-04/postgres-appdb_2020-10-04_09-11-24.sql.gz

Already clean ...

waiting for server to start....................
The server started in 0h:0m:22s.

Restoring from backup ...
Restoring '/backups/weekly/2020-10-04/postgres-appdb_2020-10-04_09-11-24.sql.gz' to '127.0.0.1/appdb' ...
waiting for server to shut down.... done
server stopped
Cleaning up ...

Successfully verified backup: /backups/weekly/2020-10-04/postgres-appdb_2020-10-04_09-11-24.sql.gz
The restored database contained 32 tables, and is 17 MB in size.

Elapsed time: 0h:0m:38s - Status Code: 0
WadeBarnes commented 4 years ago

Existing build configurations may override the FROM image specified in the Dockerfile. Therefore in order to pick up the changes (the updated Postgres image) the end user may need to update the build for their backup container.

image

to

image

  strategy:
    dockerStrategy:
      dockerfilePath: Dockerfile
      from:
        kind: DockerImage
        name: 'registry.access.redhat.com/rhscl/postgresql-10-rhel7:latest'
    type: Docker

to

  strategy:
    dockerStrategy:
      dockerfilePath: Dockerfile
    type: Docker

Note: The sample build template (backup-build.json) does not contain such an override, therefore the FROM image defined in the Dockerfile will be used.

WadeBarnes commented 4 years ago

@ikethecoder, would you be able to DM (via RC, or email) your RC handle and which team you're on so I can provide acknowledgment in the release announcement?