Add support for importing an existing Postgres database

This commit is contained in:
Slavi Pantaleev
2019-01-01 14:40:48 +02:00
parent f472c1b9e5
commit 6d89319822
5 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# Importing an existing Postgres database from another installation (optional)
Run this if you'd like to import your database from a previous installation of Matrix Synapse.
(don't forget to import your `media_store` files as well - see [the restoring media store guide](restoring-media-store.md)).
## Prerequisites
For this to work, **the database name in Postgres must match** what this playbook uses.
This playbook uses a Postgres database name of `homeserver` by default (controlled by the `matrix_postgres_db_name` variable).
If your database name differs, be sure to change `matrix_postgres_db_name` to your desired name and to re-run the playbook before proceeding.
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`).
Before doing the actual import, **you need to upload your Postgres dump file to the server**.
## Importing
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
**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!).

View File

@ -19,6 +19,8 @@ After installing, but before starting the services, you may want to do additiona
- [Importing an existing SQLite database (from another installation)](importing-sqlite.md) (optional)
- [Importing an existing Postgres database (from another installation)](importing-postgres.md) (optional)
- [Restoring `media_store` data files from an existing installation](restoring-media-store.md) (optional)