Prepare migration to 17 -> 18
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -1,18 +1,16 @@
|
|||||||
|
FROM ubuntu:noble AS build18
|
||||||
|
RUN apt update && apt upgrade -y && apt install -y wget curl tar build-essential libreadline-dev zlib1g-dev flex bison libicu-dev pkg-config
|
||||||
|
RUN wget https://ftp.postgresql.org/pub/source/v18.0/postgresql-18.0.tar.gz -O pg18.tar.gz
|
||||||
|
RUN tar -xf pg18.tar.gz
|
||||||
|
RUN cd postgresql* && ./configure --prefix=/postgres/18 && make world-bin && make install
|
||||||
|
|
||||||
FROM ubuntu:noble AS build17
|
FROM ubuntu:noble AS build17
|
||||||
RUN apt update && apt upgrade -y && apt install -y wget curl tar build-essential libreadline-dev zlib1g-dev flex bison libicu-dev pkg-config
|
RUN apt update && apt upgrade -y && apt install -y wget curl tar build-essential libreadline-dev zlib1g-dev flex bison libicu-dev pkg-config
|
||||||
|
RUN wget https://ftp.postgresql.org/pub/source/v17.6/postgresql-17.6.tar.gz -O pg17.tar.gz
|
||||||
RUN wget https://ftp.postgresql.org/pub/source/v17.2/postgresql-17.2.tar.gz -O pg17.tar.gz
|
|
||||||
RUN tar -xf pg17.tar.gz
|
RUN tar -xf pg17.tar.gz
|
||||||
RUN cd postgresql* && ./configure --prefix=/postgres/17 && make world-bin && make install
|
RUN cd postgresql* && ./configure --prefix=/postgres/17 && make world-bin && make install
|
||||||
|
|
||||||
|
|
||||||
FROM ubuntu:noble AS build16
|
|
||||||
RUN apt update && apt upgrade -y && apt install -y wget curl tar build-essential libreadline-dev zlib1g-dev flex bison libicu-dev pkg-config
|
|
||||||
|
|
||||||
RUN wget https://ftp.postgresql.org/pub/source/v16.6/postgresql-16.6.tar.gz -O pg16.tar.gz
|
|
||||||
RUN tar -xf pg16.tar.gz
|
|
||||||
RUN cd postgresql* && ./configure --prefix=/postgres/16 && make world-bin && make install
|
|
||||||
|
|
||||||
FROM ubuntu:noble
|
FROM ubuntu:noble
|
||||||
RUN apt update && apt install -y \
|
RUN apt update && apt install -y \
|
||||||
libicu74 \
|
libicu74 \
|
||||||
@@ -27,8 +25,9 @@ ENV LANG=en_US.utf8
|
|||||||
|
|
||||||
ENV POSTGRES_USER=postgres
|
ENV POSTGRES_USER=postgres
|
||||||
|
|
||||||
|
COPY --from=build18 /postgres/18 /postgres/18
|
||||||
COPY --from=build17 /postgres/17 /postgres/17
|
COPY --from=build17 /postgres/17 /postgres/17
|
||||||
COPY --from=build16 /postgres/16 /postgres/16
|
|
||||||
|
|
||||||
COPY migrate.sh /migrate.sh
|
COPY migrate.sh /migrate.sh
|
||||||
RUN chmod +x migrate.sh
|
RUN chmod +x migrate.sh
|
||||||
|
@@ -13,10 +13,10 @@ This repository will:
|
|||||||
Create an outdated database:
|
Create an outdated database:
|
||||||
```bash
|
```bash
|
||||||
mkdir test-db
|
mkdir test-db
|
||||||
docker run --rm --name testdb -u 1000 -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/var/lib/postgresql/data -it postgres:16
|
docker run --rm --name testdb --env PGDATA=/var/lib/postgresql/data -u 1000 -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/var/lib/postgresql/data -it postgres:17
|
||||||
```
|
```
|
||||||
|
|
||||||
Perform the migration (you need to replace `POSTGRES_USER` and `POSTGRES_PASSWORD` with the credentials of the root user of the database):
|
Perform the migration (you need to replace `POSTGRES_USER` and `POSTGRES_PASSWORD` with the credentials of the root user of the database):
|
||||||
```bash
|
```bash
|
||||||
docker run -u 1000 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/db --rm -it pierre42100/postgresmig:16to17
|
docker run -u 1000 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/db --rm -it pierre42100/postgresmig:17to18
|
||||||
```
|
```
|
||||||
|
2
build.sh
2
build.sh
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
docker build . -t pierre42100/postgresmig:16to17
|
docker build . -t pierre42100/postgresmig:17to18
|
@@ -17,12 +17,12 @@ cp -r "$DB_PATH" "$OLD_DB_PATH"
|
|||||||
|
|
||||||
# Initialize NEW database
|
# Initialize NEW database
|
||||||
mkdir "$NEW_DB_PATH"
|
mkdir "$NEW_DB_PATH"
|
||||||
/postgres/17/bin/initdb -D "$NEW_DB_PATH" --username "$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") || exit 1
|
/postgres/18/bin/initdb -D "$NEW_DB_PATH" --username "$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") || exit 1
|
||||||
|
|
||||||
|
|
||||||
# Perform migration
|
# Perform migration
|
||||||
cd /tmp
|
cd /tmp
|
||||||
/postgres/17/bin/pg_upgrade -b /postgres/16/bin/ -d "$OLD_DB_PATH" -D "$NEW_DB_PATH" -U "$POSTGRES_USER" || exit 2
|
/postgres/18/bin/pg_upgrade -b /postgres/17/bin/ -d "$OLD_DB_PATH" -D "$NEW_DB_PATH" -U "$POSTGRES_USER" || exit 2
|
||||||
|
|
||||||
# Configure database server
|
# Configure database server
|
||||||
echo Configure database server
|
echo Configure database server
|
||||||
|
Reference in New Issue
Block a user