Просмотр исходного кода

Fix Postgres imports going to the matrix DB by default

Well, they still do go to that DB by default,
but our docs give a better command to users, which would do the right
thing.
pull/809/head
Slavi Pantaleev 5 лет назад
Родитель
Сommit
88addd71fc
2 измененных файлов: 16 добавлений и 2 удалений
  1. +8
    -1
      docs/importing-postgres.md
  2. +8
    -1
      roles/matrix-postgres/tasks/import_postgres.yml

+ 8
- 1
docs/importing-postgres.md Просмотреть файл

@@ -21,10 +21,17 @@ Before doing the actual import, **you need to upload your Postgres dump file to

To import, run this command (make sure to replace `<server-path-to-postgres-dump.sql>` with a file path on your server):

ansible-playbook -i inventory/hosts setup.yml --extra-vars='server_path_postgres_dump=<server-path-to-postgres-dump.sql>' --tags=import-postgres
```sh
ansible-playbook -i inventory/hosts setup.yml \
--extra-vars='postgres_default_import_database=synapse server_path_postgres_dump=<server-path-to-postgres-dump.sql>' \
--tags=import-postgres
```

We specify the `synapse` database as the default import database. If your dump is a single-database dump (`pg_dump`), then we need to tell it where to go to. If you're redefining `matrix_synapse_database_database` to something other than `synapse`, please adjust it here too. For database dumps spanning multiple databases (`pg_dumpall`), you can remove the `postgres_default_import_database` definition (but it doesn't hurt to keep it too).

**Note**: `<server-path-to-postgres-dump.sql>` must be a file path to a Postgres dump file on the server (not on your local machine!).


## Troubleshooting

A table ownership issue can occur if you are importing from a Synapse installation which was both:


+ 8
- 1
roles/matrix-postgres/tasks/import_postgres.yml Просмотреть файл

@@ -35,6 +35,13 @@
postgres_import_wait_time: "{{ 7 * 86400 }}"
when: "postgres_import_wait_time|default('') == ''"

# By default, we connect and import into the main (`matrix`) database.
# Single-database dumps for Synapse may wish to import into `synapse` instead.
- name: Set postgres_default_import_database, if not provided
set_fact:
postgres_default_import_database: "{{ matrix_postgres_db_name }}"
when: "postgres_default_import_database|default('') == ''"

# Actual import work

- name: Ensure matrix-postgres is started
@@ -76,7 +83,7 @@
{{ 'gunzip |' if server_path_postgres_dump.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"
psql -v ON_ERROR_STOP=1 -h matrix-postgres --dbname={{ postgres_default_import_database }}"

# This is a hack.
# See: https://ansibledaily.com/print-to-standard-output-without-escaping/


Загрузка…
Отмена
Сохранить