Revert "Upgrade postgres"

This reverts commit 97414993dc.
This commit is contained in:
nicolas.dorier 2021-09-30 19:58:15 +09:00
parent bc3699ba67
commit d321c09ba0
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
2 changed files with 1 additions and 54 deletions

View File

@ -1,50 +0,0 @@
#!/usr/bin/env bash
set -Eeo pipefail
shopt -s extglob
CURRENT_PGVERSION=""
EXPECTED_PGVERSION="$PG_MAJOR"
if [[ -f "/var/lib/postgresql/data/PG_VERSION" ]]; then
CURRENT_PGVERSION="$(cat /var/lib/postgresql/data/PG_VERSION)"
fi
if [[ "$CURRENT_PGVERSION" != "$EXPECTED_PGVERSION" ]] && \
[[ "$CURRENT_PGVERSION" != "" ]]; then
sed -i "s/$/ $CURRENT_PGVERSION/" /etc/apt/sources.list.d/pgdg.list
apt-get update && apt-get install -y --no-install-recommends \
postgresql-$CURRENT_PGVERSION \
postgresql-contrib-$CURRENT_PGVERSION \
&& rm -rf /var/lib/apt/lists/*
export PGBINOLD="/usr/lib/postgresql/$CURRENT_PGVERSION/bin"
export PGDATABASE="/var/lib/postgresql/data"
export PGDATAOLD="/var/lib/postgresql/data/$CURRENT_PGVERSION"
export PGDATANEW="/var/lib/postgresql/data/$EXPECTED_PGVERSION"
mkdir -p "$PGDATANEW" "$PGDATAOLD"
find "$PGDATABASE" -maxdepth 1 -mindepth 1 \
-not -wholename "$PGDATAOLD" \
-not -wholename "$PGDATANEW" \
-exec mv {} "$PGDATAOLD/" \;
chmod 700 "$PGDATAOLD" "$PGDATANEW"
chown postgres .
chown -R postgres "$PGDATAOLD" "$PGDATANEW" "$PGDATABASE"
if [ ! -s "$PGDATANEW/PG_VERSION" ]; then
PGDATA="$PGDATANEW" eval "gosu postgres initdb $POSTGRES_INITDB_ARGS"
fi
gosu postgres pg_upgrade
rm $PGDATANEW/*.conf
mv $PGDATANEW/* "$PGDATABASE"
mv $PGDATAOLD/*.conf "$PGDATABASE"
rm -r "$PGDATANEW"
./delete_old_cluster.sh
rm ./analyze_new_cluster.sh
fi
if [ -f "docker-entrypoint.sh" ]; then
exec ./docker-entrypoint.sh "$@"
else
exec docker-entrypoint.sh "$@"
fi

View File

@ -3,14 +3,11 @@ version: "3"
services:
postgres:
restart: unless-stopped
image: postgres:13.4
entrypoint: ./migrate-docker-entrypoint.sh
command: postgres
image: postgres:9.6.20
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- "postgres_datadir:/var/lib/postgresql/data"
- "./postgres/migrate-docker-entrypoint.sh:/migrate-docker-entrypoint.sh:ro"
volumes:
postgres_datadir: