With a few modifications to the pg_dump
sources, you can restore the previous behaviour such that INSERT
statements do not include the schema name.
To build a Docker image with these changes, create a Dockerfile
with the following content:
FROM alpine:latest
WORKDIR /usr/src/postgresql
RUN apk add --no-cache \
alpine-sdk \
perl \
readline-dev \
zlib-dev \
bison \
flex \
git \
coreutils \
linux-headers \
util-linux-dev
RUN git clone \
--depth 1 \
--branch feat/schema-less-pg-dump-11 \
https://github.com/tindzk/postgres.git .
RUN ./configure && make
RUN cp src/bin/pg_dump/pg_dump /usr/bin/ && \
cp ./src/interfaces/libpq/libpq.so* /usr/lib/
RUN apk del alpine-sdk \
&& rm -rf /var/cache/apk/* /usr/src/postgresql
CMD ["pg_dump"]
Afterwards, use it as follows:
docker build -t pgdump-11 .
docker run \
-e PGPASSWORD=$db_password \
-v "$(pwd)":/data/ \
pgdump-11 \
pg_dump \
--verbose \
"postgres://$db_user@$db_host:$db_port/$db_name" \
--schema $db_schema \
--file /data/dump.sql
This approach is more robust than pattern matching and avoids the risk of false positives.