Show Postgres import command and mention manual importing

development
Slavi Pantaleev 6 years ago
parent 8d186e5194
commit 0392822aa7

@ -30,7 +30,6 @@
postgres_start_wait_time: 15 postgres_start_wait_time: 15
when: "postgres_start_wait_time|default('') == ''" when: "postgres_start_wait_time|default('') == ''"
# Actual import work # Actual import work
- name: Ensure matrix-postgres is started - name: Ensure matrix-postgres is started
@ -52,14 +51,26 @@
msg: "Could not find existing Postgres installation" msg: "Could not find existing Postgres installation"
when: "not matrix_postgres_detected_existing" when: "not matrix_postgres_detected_existing"
- name: Perform Postgres database import - name: Generate Postgres database import command
command: | set_fact:
/usr/bin/docker run --rm --name matrix-postgres-import \ matrix_postgres_import_command: >-
--network={{ matrix_docker_network }} \ /usr/bin/docker run --rm --name matrix-postgres-import
--env-file={{ matrix_postgres_base_path }}/env-postgres-psql \ --network={{ matrix_docker_network }}
-v {{ server_path_postgres_dump }}:{{ server_path_postgres_dump }}:ro \ --env-file={{ matrix_postgres_base_path }}/env-postgres-psql
-v {{ server_path_postgres_dump }}:{{ server_path_postgres_dump }}:ro
--entrypoint=/bin/sh --entrypoint=/bin/sh
{{ matrix_postgres_docker_image_latest }} {{ matrix_postgres_docker_image_latest }}
-c 'cat {{ server_path_postgres_dump }} | \ -c 'cat {{ server_path_postgres_dump }} |
{{ 'gunzip |' if server_path_postgres_dump.endswith('.gz') else '' }} {{ 'gunzip |' if server_path_postgres_dump.endswith('.gz') else '' }}
psql -v ON_ERROR_STOP=1 -h matrix-postgres' psql -v ON_ERROR_STOP=1 -h matrix-postgres'
- name: Note about Postgres importing alternative
debug:
msg: >
Importing Postgres database using the following command: `{{ matrix_postgres_import_command }}`.
If this crashes, you can stop Postgres (`systemctl stop matrix-postgres`),
delete its existing data (`rm -rf {{ matrix_postgres_data_path }}/*`), start it again (`systemctl start matrix-postgres`)
and manually run the above import command directly on the server.
- name: Perform Postgres database import
command: "{{ matrix_postgres_import_command }}"

Loading…
Cancel
Save