Procházet zdrojové kódy

Update importing-postgres.md

some details, especially on repeating the import.
pull/1436/head
felixx9 před 4 roky
committed by GitHub
rodič
revize
7bcdeb821a
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 4AEE18F83AFDEB23
1 změnil soubory, kde provedl 19 přidání a 2 odebrání
  1. +19
    -2
      docs/importing-postgres.md

+ 19
- 2
docs/importing-postgres.md Zobrazit soubor

@@ -12,7 +12,8 @@ If your database name differs, be sure to change `matrix_synapse_database_databa


The playbook supports importing Postgres dump files in **text** (e.g. `pg_dump > dump.sql`) or **gzipped** formats (e.g. `pg_dump | gzip -c > dump.sql.gz`). The playbook supports importing Postgres dump files in **text** (e.g. `pg_dump > dump.sql`) or **gzipped** formats (e.g. `pg_dump | gzip -c > dump.sql.gz`).


Importing multiple databases (as dumped by `pg_dumpall`) is also supported.
Importing multiple databases (as dumped by `pg_dumpall`) is also supported.
But the migration might be a good moment, to "reset" a not properly working bridge. Be aware, that it might affect all users (new link to bridge, new roomes, ...)


Before doing the actual import, **you need to upload your Postgres dump file to the server** (any path is okay). Before doing the actual import, **you need to upload your Postgres dump file to the server** (any path is okay).


@@ -32,6 +33,7 @@ ansible-playbook -i inventory/hosts setup.yml \


## Troubleshooting ## Troubleshooting


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


- migrated from SQLite to Postgres, and - migrated from SQLite to Postgres, and
@@ -71,6 +73,8 @@ Note that if the previous import failed with an error it may have made changes w
ERROR: relation \"access_tokens\" already exists ERROR: relation \"access_tokens\" already exists
``` ```


### Repeat import

In this case you can use the command suggested in the import task to clear the database before retrying the import: In this case you can use the command suggested in the import task to clear the database before retrying the import:


```Shell ```Shell
@@ -78,5 +82,18 @@ In this case you can use the command suggested in the import task to clear the d
# rm -rf /matrix/postgres/data/* # rm -rf /matrix/postgres/data/*
# systemctl start matrix-postgres # systemctl start matrix-postgres
``` ```
Now on your local machine run `ansible-playbook -i inventory/hosts setup.yml -K --tags=setup-postgres` to prepare the database roles etc.
If not, you probably get this error. `synapse` is the correct table owner, but the role is missing in database.
```
"ERROR: role synapse does not exist"
```

Once the database is clear and the ownership of the tables has been fixed in the SQL file, the import task should succeed.
Check, if `--dbname` is set to `synapse` (not `matrix`) and replace paths (or even better, copy this line from your terminal)

```
/usr/bin/env docker run --rm --name matrix-postgres-import --log-driver=none --user=998:1001 --cap-drop=ALL --network=matrix --env-file=/matrix/postgres/env-postgres-psql --mount type=bind,src=/migration/synapse_dump.sql,dst=/synapse_dump.sql,ro --entrypoint=/bin/sh docker.io/postgres:14.1-alpine -c "cat /synapse_dump.sql | grep -vE '^(CREATE|ALTER) ROLE (matrix)(;| WITH)' | grep -vE '^CREATE DATABASE (matrix)\s' | psql -v ON_ERROR_STOP=1 -h matrix-postgres --dbname=synapse"
```



Once the database is clear and the ownership of the tables has been fixed in the SQL file, the import task should succeed.

Načítá se…
Zrušit
Uložit