WIP
This commit is contained in:
parent
deef51e042
commit
2ded4f6ed9
19
Dockerfile
19
Dockerfile
@ -14,6 +14,23 @@ RUN tar -xf pg16.tar.gz
|
|||||||
RUN cd postgresql* && ./configure --prefix=/postgres/16 && make world-bin && make install
|
RUN cd postgresql* && ./configure --prefix=/postgres/16 && make world-bin && make install
|
||||||
|
|
||||||
FROM ubuntu:noble
|
FROM ubuntu:noble
|
||||||
RUN apt update && apt install -y libicu74 libreadline8t64 curl wget nano && rm -rf /var/lib/apt/lists/*
|
RUN apt update && apt install -y \
|
||||||
|
libicu74 \
|
||||||
|
libreadline8t64 \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
nano \
|
||||||
|
locales \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
|
||||||
|
ENV LANG=en_US.utf8
|
||||||
|
|
||||||
|
ENV POSTGRES_USER=postgres
|
||||||
|
|
||||||
COPY --from=build17 /postgres/17 /postgres/17
|
COPY --from=build17 /postgres/17 /postgres/17
|
||||||
COPY --from=build16 /postgres/16 /postgres/16
|
COPY --from=build16 /postgres/16 /postgres/16
|
||||||
|
|
||||||
|
COPY migrate.sh /migrate.sh
|
||||||
|
RUN chmod +x migrate.sh
|
||||||
|
|
||||||
|
CMD ["/migrate.sh"]
|
@ -1,6 +1,13 @@
|
|||||||
# Docker migration helper
|
# Docker migration helper
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
|
Create an outdated database
|
||||||
|
```bash
|
||||||
|
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 -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/var/lib/postgresql/data -it postgres:16
|
|
||||||
|
Perform the migration:
|
||||||
|
```bash
|
||||||
|
./build.sh && docker run -u 1000 -v $(pwd)/test-db:/db --rm -it pierre42100/postgresmig:16to17
|
||||||
```
|
```
|
28
migrate.sh
Normal file
28
migrate.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo Migrate PostgreSQL version
|
||||||
|
|
||||||
|
DB_PATH=/db
|
||||||
|
OLD_DB_PATH=/tmp/old_db
|
||||||
|
|
||||||
|
# Run database on a COPY of the database
|
||||||
|
cp -r "$DB_PATH" "$OLD_DB_PATH"
|
||||||
|
|
||||||
|
# Start the database in the background
|
||||||
|
/postgres/16/bin/postgres -D /tmp/old_db/ &
|
||||||
|
|
||||||
|
while true;
|
||||||
|
do
|
||||||
|
echo Waiting for database...
|
||||||
|
if echo "\q" | /postgres/16/bin/psql -U "$POSTGRES_USER";
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Perform dump
|
||||||
|
|
||||||
|
|
||||||
|
# Stop database
|
||||||
|
#pkill postgres
|
||||||
|
|
||||||
|
bash
|
Loading…
Reference in New Issue
Block a user