mirror of
https://git.koehn.com/docker/postgres-wal-g.git
synced 2026-11-25 17:43:20 -06:00
Compare commits
93
Commits
8
..
15.2-v2.0.1-9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6ca092a14 | ||
|
|
90ad5e4126 | ||
|
|
a6e6872913 | ||
|
|
b6a266eeb3 | ||
|
|
28b4645545 | ||
|
|
b89fdb75cb | ||
|
|
93013a5b39 | ||
|
|
20b012a6a0 | ||
|
|
83fa1e24a6 | ||
|
|
36f146a58f | ||
|
|
caf5c50aa6 | ||
|
|
c0dabcc230 | ||
|
|
192afe1453 | ||
|
|
69f99303d4 | ||
|
|
ef80955920 | ||
|
|
2ae1d24f9a | ||
|
|
2b8df13fda | ||
|
|
c1346e5f41 | ||
|
|
2f98080099 | ||
|
|
acadcd0db6 | ||
|
|
0670df99dc | ||
|
|
9af7b9169d | ||
|
|
f2fa1d42d6 | ||
|
|
4666db46fc | ||
|
|
6565723c06 | ||
|
|
a4ca8d4b45 | ||
|
|
25642d5ed8 | ||
|
|
ac557f48c2 | ||
|
|
9fdba2423e | ||
|
|
3adadf55b3 | ||
|
|
5b3cd141cb | ||
|
|
2f6dc3a509 | ||
|
|
21c53dc4dd | ||
|
|
f2ef1c9d00 | ||
|
|
4b02d05230 | ||
|
|
2d1dea3953 | ||
|
|
7936f2a660 | ||
|
|
f884fca8d3 | ||
|
|
808d390383 | ||
|
|
888a8e06bf | ||
|
|
8e6481be9b | ||
|
|
bd622797b1 | ||
|
|
d18b5088ad | ||
|
|
c030b76a4c | ||
|
|
ed3f8308bc | ||
|
|
e5067b4257 | ||
|
|
e34430fd7e | ||
|
|
67f8f0cb65 | ||
|
|
a7020c5d4e | ||
|
|
a8028d9962 | ||
|
|
99ef19d076 | ||
|
|
a4118b3a0f | ||
|
|
21f3485321 | ||
|
|
0b977ac06b | ||
|
|
0043e3f3a4 | ||
|
|
b5dbec4366 | ||
|
|
8af3605145 | ||
|
|
fdb7f1c6bf | ||
|
|
6e75b71775 | ||
|
|
80706a20c7 | ||
|
|
1ca880cf44 | ||
|
|
b66f2886bb | ||
|
|
55b02b6caa | ||
|
|
3160eaf1b6 | ||
|
|
ae5912f70f | ||
|
|
f648887066 | ||
|
|
4a4d87ba5d | ||
|
|
7fa04795a8 | ||
|
|
89f76bb78b | ||
|
|
642632c60c | ||
|
|
f301fad22e | ||
|
|
365ef7da9f | ||
|
|
ceb542e680 | ||
|
|
83459c3eee | ||
|
|
e3cee34644 | ||
|
|
6ce0b371be | ||
|
|
f92168528e | ||
|
|
10af957331 | ||
|
|
d8e1e1f39b | ||
|
|
56aa0e2ca2 | ||
|
|
30f3363b8e | ||
|
|
72c13d458e | ||
|
|
6f6dd9bca6 | ||
|
|
fc6bb76110 | ||
|
|
d3feaff8e1 | ||
|
|
e779a43c2f | ||
|
|
cc2096c4b9 | ||
|
|
a554117ba1 | ||
|
|
a08e138569 | ||
|
|
18b0d9b0ee | ||
|
|
5b59617f84 | ||
|
|
c3425c6064 | ||
|
|
bc070c6dae |
No files matched your search
+19
-15
@@ -1,25 +1,29 @@
|
||||
stages:
|
||||
- build
|
||||
|
||||
build-9.6:
|
||||
build:
|
||||
stage: build
|
||||
timeout: 3h
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:debug
|
||||
name: moby/buildkit:latest
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- echo "{\"auths\":{\"index.docker.io\":{\"username\":\"$DOCKER_LOGIN\",\"password\":\"$DOCKER_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination koehn/postgres-wal-g:9.6-$CI_COMMIT_TAG --build-arg BASE=9.6
|
||||
only:
|
||||
- tags
|
||||
|
||||
build-11.1:
|
||||
stage: build
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:debug
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- echo "{\"auths\":{\"index.docker.io\":{\"username\":\"$DOCKER_LOGIN\",\"password\":\"$DOCKER_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination koehn/postgres-wal-g:11.1-$CI_COMMIT_TAG --build-arg BASE=11.1
|
||||
- |
|
||||
mkdir /root/.docker
|
||||
cat > /root/.docker/config.json <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"https://index.docker.io/v1/": {
|
||||
"auth":"${DOCKER_AUTH}"
|
||||
},
|
||||
"${CI_REGISTRY}": {
|
||||
"username": "${CI_REGISTRY_USER}",
|
||||
"password": "${CI_REGISTRY_PASSWORD}"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
- buildctl-daemonless.sh build --frontend=dockerfile.v0 --local context=$CI_PROJECT_DIR --local dockerfile=$CI_PROJECT_DIR --output type=image,name=docker.io/koehn/postgres-wal-g:14.2-$CI_COMMIT_TAG,push=true --opt build-arg:BASE=14.2 --opt build-arg:WALG_RELEASE=$(echo $CI_COMMIT_TAG | awk -F '-' '{print $1}') --opt platform=linux/amd64
|
||||
only:
|
||||
- tags
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
pipeline:
|
||||
build-image:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
when:
|
||||
event: tag
|
||||
secrets: [ docker_username, docker_password ]
|
||||
settings:
|
||||
repo: koehn/postgres-wal-g
|
||||
tag: ${CI_COMMIT_TAG}
|
||||
platforms: linux/amd64
|
||||
mtu: 1300
|
||||
build_args:
|
||||
- BASE=${CI_COMMIT_TAG:0:4}
|
||||
- WALG_RELEASE=${CI_COMMIT_TAG:5:6}
|
||||
|
||||
+16
-3
@@ -1,10 +1,23 @@
|
||||
ARG BASE
|
||||
|
||||
FROM golang:1 as build
|
||||
|
||||
ARG WALG_RELEASE=v1.1
|
||||
|
||||
RUN apt-get update && apt-get install -qqy --no-install-recommends --no-install-suggests cmake liblzo2-dev libsodium23 libsodium-dev && \
|
||||
cd /go/src/ && \
|
||||
git clone -b $WALG_RELEASE --recurse-submodules https://github.com/wal-g/wal-g.git && \
|
||||
cd wal-g && \
|
||||
GOBIN=/go/bin USE_LIBSODIUM=1 USE_LZO=1 make install_and_build_pg
|
||||
|
||||
|
||||
FROM postgres:$BASE
|
||||
|
||||
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||
apt-get update -qq && \
|
||||
apt-get install -qqy curl ca-certificates vim && \
|
||||
cd /usr/local/bin && curl -L https://github.com/wal-g/wal-g/releases/download/v0.2.2/wal-g.linux-amd64.tar.gz | tar xzf -
|
||||
apt-get update && \
|
||||
apt-get install -qqy curl ca-certificates libsodium23 vim
|
||||
|
||||
COPY --from=build /go/src/wal-g/main/pg/wal-g /usr/local/bin/wal-g
|
||||
|
||||
COPY wal-g /wal-g
|
||||
@@ -1,8 +1,10 @@
|
||||
[](https://woodpecker.koehn.com/docker/postgres-wal-g)
|
||||
|
||||
# Postgres WAL-G
|
||||
|
||||
This image extends the stock [Postgres Image](https://hub.docker.com/_/postgres/)
|
||||
and adds [WAL-G](https://github.com/wal-g/wal-g) support, along with some
|
||||
helpful scripts. It allows you to simply and easily create continuous
|
||||
helpful scripts. It allows you to simply and easily create continuous, encrypted
|
||||
archives of Postgres databases in S3-compatible storage.
|
||||
|
||||
## Environment
|
||||
@@ -12,12 +14,13 @@ compatible provider, and set a few environment variables:
|
||||
* `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` that can read/write files
|
||||
to your bucket
|
||||
* `AWS_ENDPOINT` (et al) to tell WAL-G where to archive (see
|
||||
[WAL-G documentation](https://github.com/wal-g/wal-g) for details)
|
||||
[WAL-G documentation](https://github.com/wal-g/wal-g/blob/master/docs/PostgreSQL.md) for details)
|
||||
* `WALG_S3_PREFIX` to tell WAL-G which bucket and prefix you'd like to use
|
||||
* `WALG_LIBSODIUM_KEY` to encrypt the files stored in S3
|
||||
|
||||
## Configuration
|
||||
In your `/varlib/postgresql/data/pgsql/postgresql.conf` file, set your [archive
|
||||
settings](https://www.postgresql.org/docs/9.1/continuous-archiving.html).
|
||||
In your `/var/lib/postgresql/data/pgsql/postgresql.conf` file, set your [archive
|
||||
settings](https://www.postgresql.org/docs/current/continuous-archiving.html).
|
||||
Importantly, you should set `archive_mode = on` and
|
||||
`archive_command = 'wal-g wal-push %p'`. This will
|
||||
tell Postgres to have WAL-G send WAL files to S3.
|
||||
@@ -44,5 +47,4 @@ If you start your recovered backup, be sure to turn `archive_mode = off` to avoi
|
||||
pushing additional WAL files to S3!
|
||||
|
||||
## Postgres Versions
|
||||
Currently I build for Postgres 9.6 and Postgres 11. Be advised that 9.6 is the
|
||||
earliest version that WAL-G supports.
|
||||
Currently I build for Postgres 15, but you can build for whatever version that wal-g supports.
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
REV=$1
|
||||
# e.g., 14.3
|
||||
PG_VERSION=$1
|
||||
|
||||
#e.g., v2.0.1
|
||||
WALG_VERSION=$2
|
||||
IMAGE_NAME=koehn/postgres-wal-g
|
||||
|
||||
build_image() {
|
||||
BASE=$1
|
||||
IMAGE=$IMAGE_NAME:$BASE-$REV
|
||||
|
||||
docker build --pull -t "$IMAGE" --build-arg BASE=$BASE .
|
||||
docker push $IMAGE
|
||||
IMAGE=$IMAGE_NAME:$BASE-$WALG_VERSION
|
||||
docker buildx build --builder k3s-sd -t $IMAGE --push . --build-arg BASE=$PG_VERSION --build-arg WALG_RELEASE=$WALG_VERSION --ulimit memlock=16384:16384
|
||||
}
|
||||
|
||||
build_image "11.1" "$REV"
|
||||
build_image "9.6"
|
||||
build_image "$PG_VERSION" "$WALG_VERSION"
|
||||
|
||||
wait
|
||||
+7
-1
@@ -1,3 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
wal-g backup-push /var/lib/postgresql/data/pgsql
|
||||
# A simple script to push a backup of your database.
|
||||
|
||||
if [ -z ${PGDATA+x} ]; then
|
||||
export PGDATA=/var/lib/postgresql/data/pgsql
|
||||
fi
|
||||
|
||||
wal-g backup-push "$PGDATA"
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
set -e
|
||||
|
||||
export DATA=/var/lib/postgresql/data/pgsql
|
||||
if [ -z ${PGDATA+x} ]; then
|
||||
export PGDATA=/var/lib/postgresql/data/pgsql
|
||||
fi
|
||||
|
||||
export PG_VERSION=$(ls /usr/lib/postgresql/)
|
||||
|
||||
# disable recovery mode, re-enable remote connections and archive mode
|
||||
mv $DATA/pg_hba.conf.orig $DATA/pg_hba.conf
|
||||
sed -i -e 's/^archive_mode = off/archive_mode = on/' $DATA/postgresql.conf
|
||||
mv $PGDATA/pg_hba.conf.orig $PGDATA/pg_hba.conf
|
||||
mv $PGDATA/postgresql.conf.orig $PGDATA/postgresql.conf
|
||||
sed -i -e 's/^archive_mode = off/archive_mode = on/' $PGDATA/postgresql.conf
|
||||
|
||||
cat <<EOF
|
||||
******************
|
||||
@@ -17,5 +21,5 @@ cat <<EOF
|
||||
******************
|
||||
EOF
|
||||
|
||||
bash -c "sleep 3 && /usr/lib/postgresql/$PG_VERSION/bin/pg_ctl stop -D $DATA" &
|
||||
bash -c "sleep 3 && /usr/lib/postgresql/$PG_VERSION/bin/pg_ctl stop -D $PGDATA" &
|
||||
|
||||
+23
-7
@@ -1,5 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Recovery script:
|
||||
# * Calls wal-g to recover the latest database
|
||||
# * Configures postgres to enter recovery mode by:
|
||||
# * 1. Setting signal
|
||||
# * 2. Appending wal-g recovery commands onto postgresql.conf
|
||||
# * 3. Configuring postgres to only allow connections from localhost, preventing concurrent updates
|
||||
# * 4. Disabling archive mode so as not to corrupt S3 backups
|
||||
# * Starts postgres
|
||||
#
|
||||
# When recovery is done, hit ^C and start database using `/docker-entrypoint.sh postgres` and you should be able to connect to the database and verify backups are OK.
|
||||
# If you get an error message, DON'T PANIC! Just read the message and do what it tells you to do.
|
||||
|
||||
if [ $(id -u) == "0" ] ; then
|
||||
echo "this command must be run as the postgres user."
|
||||
exit 1
|
||||
@@ -7,17 +19,21 @@ fi
|
||||
|
||||
set -e
|
||||
|
||||
DATA=/var/lib/postgresql/data/pgsql
|
||||
if [ -z ${PGDATA+x} ]; then
|
||||
export PGDATA=/var/lib/postgresql/data/pgsql
|
||||
fi
|
||||
|
||||
# fetch most recent full backup
|
||||
wal-g backup-fetch $DATA LATEST
|
||||
wal-g backup-fetch $PGDATA LATEST
|
||||
|
||||
# enable recovery mode, disable remote connections and archive mode
|
||||
cp /wal-g/recovery.conf $DATA/
|
||||
mv $DATA/pg_hba.conf $DATA/pg_hba.conf.orig
|
||||
cp /wal-g/pg_hba.conf $DATA/pg_hba.conf
|
||||
sed -i -e 's/^archive_mode = on/archive_mode = off/' $DATA/postgresql.conf
|
||||
touch $PGDATA/recovery.signal
|
||||
cp $PGDATA/postgresql.conf $PGDATA/postgresql.conf.orig
|
||||
cat /wal-g/recovery.conf >> $PGDATA/postgresql.conf
|
||||
mv $PGDATA/pg_hba.conf $PGDATA/pg_hba.conf.orig
|
||||
cp /wal-g/pg_hba.conf $PGDATA/pg_hba.conf
|
||||
sed -i -e 's/^archive_mode = on/archive_mode = off/' $PGDATA/postgresql.conf
|
||||
|
||||
PG_VERSION=$(ls /usr/lib/postgresql/)
|
||||
|
||||
/usr/lib/postgresql/$PG_VERSION/bin/pg_ctl start -D $DATA
|
||||
/usr/lib/postgresql/$PG_VERSION/bin/pg_ctl start -D $PGDATA
|
||||
Reference in new issue
Block a user