mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-12-24 18:08:28 +01:00
Update importing-postgres.md with individual DB and repeat-import information (#1437)
* Update importing-postgres.md Additional deatails, mostly on repeating import. Structure troubleshouting section. * Update importing-postgres.md removing -K * Fix path typo Co-authored-by: Slavi Pantaleev <slavi@devture.com>
This commit is contained in:
parent
9ab7b9fa58
commit
d51a9118d3
@ -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
|
||||||
@ -79,4 +83,20 @@ In this case you can use the command suggested in the import task to clear the d
|
|||||||
# systemctl start matrix-postgres
|
# systemctl start matrix-postgres
|
||||||
```
|
```
|
||||||
|
|
||||||
Once the database is clear and the ownership of the tables has been fixed in the SQL file, the import task should succeed.
|
Now on your local machine run `ansible-playbook -i inventory/hosts setup.yml --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"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Hints
|
||||||
|
|
||||||
|
To open psql terminal run `/usr/local/bin/matrix-postgres-cli`
|
||||||
|
Loading…
Reference in New Issue
Block a user