Add support for backing up / importing all Postgres databases/users
This commit is contained in:
@ -12,6 +12,8 @@ If your database name differs, be sure to change `matrix_postgres_db_name` to yo
|
||||
|
||||
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.
|
||||
|
||||
Before doing the actual import, **you need to upload your Postgres dump file to the server** (any path is okay).
|
||||
|
||||
|
||||
|
@ -40,16 +40,18 @@ To make a back up of the current PostgreSQL database, make sure it's running and
|
||||
```bash
|
||||
docker run \
|
||||
--rm \
|
||||
--network matrix \
|
||||
--network=matrix \
|
||||
--env-file=/matrix/postgres/env-postgres-psql \
|
||||
postgres:12.0-alpine \
|
||||
pg_dump -h matrix-postgres \
|
||||
pg_dumpall -h matrix-postgres \
|
||||
| gzip -c \
|
||||
> /postgres.sql.gz
|
||||
```
|
||||
|
||||
If you are using an [external Postgres server](configuring-playbook-external-postgres.md), the above command will not work, because the credentials file (`/matrix/postgres/env-postgres-psql`) is not available.
|
||||
|
||||
Restoring a backup made this way can be done by [importing it](importing-postgres.md).
|
||||
|
||||
|
||||
## Upgrading PostgreSQL
|
||||
|
||||
@ -64,7 +66,7 @@ This playbook can upgrade your existing Postgres setup with the following comman
|
||||
|
||||
ansible-playbook -i inventory/hosts setup.yml --tags=upgrade-postgres
|
||||
|
||||
**The old Postgres data directory is backed up** automatically, by renaming to `/matrix/postgres-auto-upgrade-backup`.
|
||||
**The old Postgres data directory is backed up** automatically, by renaming it to `/matrix/postgres-auto-upgrade-backup`.
|
||||
To rename to a different path, pass some extra flags to the command above, like this: `--extra-vars="postgres_auto_upgrade_backup_data_path=/another/disk/matrix-postgres-before-upgrade"`
|
||||
|
||||
The auto-upgrade-backup directory stays around forever, until you **manually decide to delete it**.
|
||||
@ -72,5 +74,4 @@ The auto-upgrade-backup directory stays around forever, until you **manually dec
|
||||
As part of the upgrade, the database is dumped to `/tmp`, an upgraded and empty Postgres server is started, and then the dump is restored into the new server.
|
||||
To use a different directory for the dump, pass some extra flags to the command above, like this: `--extra-vars="postgres_dump_dir=/directory/to/dump/here"`
|
||||
|
||||
**ONLY one database is migrated** (the one specified in `matrix_postgres_db_name`, named `homeserver` by default).
|
||||
If you've created other databases in that database instance (something this playbook never does and never advises), data will be lost.
|
||||
**All databases, roles, etc. on the Postgres server are migrated**.
|
||||
|
Reference in New Issue
Block a user