WIP: feat(postgres): actually use proper dump+restore procedure over psql misuse

This commit is contained in:
transcaffeine 2022-05-27 09:14:12 +02:00
parent fe0668bb2f
commit b784feb525
Signed by: transcaffeine
GPG Key ID: 03624C433676E465

View File

@ -87,9 +87,10 @@
--entrypoint=/bin/sh
--mount type=bind,src={{ postgres_dump_dir }},dst=/out
{{ matrix_postgres_detected_version_corresponding_docker_image }}
-c "pg_dumpall -h matrix-postgres
{{ '| gzip -c ' if postgres_dump_name.endswith('.gz') else '' }}
> /out/{{ postgres_dump_name }}"
-c "pg_dumpall -h matrix-postgres --format=directory -j 8 -f /out/postgres"
# {{ '| gzip -c ' if postgres_dump_name.endswith('.gz') else '' }}
# > /out/{{ postgres_dump_name }}"
- name: Ensure matrix-postgres is stopped
service:
@ -133,11 +134,13 @@
--entrypoint=/bin/sh
--mount type=bind,src={{ postgres_dump_dir }},dst=/in,ro
{{ matrix_postgres_docker_image_latest }}
-c "cat /in/{{ postgres_dump_name }} |
{{ 'gunzip |' if postgres_dump_name.endswith('.gz') else '' }}
grep -vE '{{ matrix_postgres_import_roles_ignore_regex }}' |
grep -vE '{{ matrix_postgres_import_databases_ignore_regex }}' |
psql -v ON_ERROR_STOP=1 -h matrix-postgres"
-c "pg_restore -j 10 -h matrix-postgres"
# -c "cat /in/{{ postgres_dump_name }} |
# {{ 'gunzip |' if postgres_dump_name.endswith('.gz') else '' }}
# grep -vE '{{ matrix_postgres_import_roles_ignore_regex }}' |
# grep -vE '{{ matrix_postgres_import_databases_ignore_regex }}' |
# psql -v ON_ERROR_STOP=1 -h matrix-postgres"
# This is a hack.
# See: https://ansibledaily.com/print-to-standard-output-without-escaping/