Upgrade to Postgres 16. During upgrade migrate also configuration files
This commit is contained in:
@@ -7,7 +7,7 @@ RUN go mod download
|
||||
|
||||
RUN mkdir bin/ && go build -o bin/ ./...
|
||||
|
||||
FROM postgis/postgis:15-master
|
||||
FROM postgis/postgis:16-master
|
||||
|
||||
COPY --from=builder /usr/local/src/pg_autoconfig/bin/pg_autoconfig /
|
||||
|
||||
@@ -15,9 +15,9 @@ COPY upgrade-entrypoint.sh /
|
||||
|
||||
RUN localedef -i cs_CZ -c -f UTF-8 -A /usr/share/locale/locale.alias cz_CZ.UTF-8 && \
|
||||
apt-get update && apt-get install -y \
|
||||
postgresql-15 postgresql-client-15 postgresql-15-auto-failover pg-auto-failover-cli postgresql-15-pgvector \
|
||||
postgresql-16 postgresql-client-16 postgresql-16-auto-failover pg-auto-failover-cli postgresql-16-pgvector \
|
||||
# Include previous postgres version to allow automatic upgrade
|
||||
postgresql-14 postgresql-14-postgis-3 postgresql-14-pgvector && \
|
||||
postgresql-15 postgresql-15-postgis-3 postgresql-15-pgvector && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
chmod +x /upgrade-entrypoint.sh
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ set -e
|
||||
|
||||
DATA_DIR="/var/lib/postgresql/data"
|
||||
OLD_VERSION_FILE="$DATA_DIR/PG_VERSION"
|
||||
NEW_VERSION="15"
|
||||
OLD_BIN="/usr/lib/postgresql/14/bin"
|
||||
NEW_BIN="/usr/lib/postgresql/15/bin"
|
||||
NEW_VERSION="16"
|
||||
OLD_BIN="/usr/lib/postgresql/15/bin"
|
||||
NEW_BIN="/usr/lib/postgresql/16/bin"
|
||||
|
||||
if [ -f "$OLD_VERSION_FILE" ]; then
|
||||
OLD_VERSION=$(cat "$OLD_VERSION_FILE")
|
||||
@@ -45,9 +45,19 @@ if [ -f "$OLD_VERSION_FILE" ]; then
|
||||
# Exit to prevent the script from continuing
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Migrate configuration files
|
||||
echo "Upgrade complete. Cleaning up..."
|
||||
cp "$DATA_DIR/old_data/pg_hba.conf" "$DATA_DIR/new_data/pg_hba.conf"
|
||||
cp "$DATA_DIR/old_data/postgresql.conf" "$DATA_DIR/new_data/postgresql.conf"
|
||||
if [ -f "$DATA_DIR/old_data/pg_ident.conf" ]; then
|
||||
cp "$DATA_DIR/old_data/pg_ident.conf" "$DATA_DIR/new_data/pg_ident.conf"
|
||||
fi
|
||||
|
||||
# Ensure the postgres user owns the restored files
|
||||
chown postgres:postgres "$DATA_DIR"/new_data/*.conf
|
||||
|
||||
# Clean-up
|
||||
echo "Upgrade complete. Cleaning up..."
|
||||
rm -rf $DATA_DIR/old_data
|
||||
mv $DATA_DIR/new_data/* $DATA_DIR/
|
||||
rmdir $DATA_DIR/new_data
|
||||
|
||||
Reference in New Issue
Block a user