From 009bb1b77674e99dff110277383a5d414a66bec4 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 1 Nov 2018 09:45:48 +0200 Subject: [PATCH] Add support for configuring Postgres auto-upgrade-backup path --- docs/maintenance-upgrading-postgres.md | 8 +++++--- roles/matrix-server/tasks/upgrade_postgres.yml | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/maintenance-upgrading-postgres.md b/docs/maintenance-upgrading-postgres.md index 6e6a1b3b..c41712f3 100644 --- a/docs/maintenance-upgrading-postgres.md +++ b/docs/maintenance-upgrading-postgres.md @@ -3,15 +3,17 @@ If you're not using an external Postgres server, this playbook initially installs Postgres for you. Once installed like that, this playbook attempts to preserve the Postgres version it starts with. -This is because newer Postgres versions cannot start with data generated by an older Postgres version. +This is because newer Postgres versions cannot start with data generated by older Postgres versions. An upgrade must be performed. This playbook can upgrade your existing Postgres setup with the following command: ansible-playbook -i inventory/hosts setup.yml --tags=upgrade-postgres -**The old Postgres data directory is backed up** (by renaming to `/matrix/postgres-auto-upgrade-backup`). -It stays around forever, until you **manually decide to delete it**. +**The old Postgres data directory is backed up** by renaming to `/matrix/postgres-auto-upgrade-backup`, by default. +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**. As part of the upgrade, the database is dumped to `/tmp`, upgraded and then restored from that dump. To use a different directory, pass some extra flags to the command above, like this: `--extra-vars="postgres_dump_dir=/directory/to/dump/here"` diff --git a/roles/matrix-server/tasks/upgrade_postgres.yml b/roles/matrix-server/tasks/upgrade_postgres.yml index a18df9e1..e42353f1 100644 --- a/roles/matrix-server/tasks/upgrade_postgres.yml +++ b/roles/matrix-server/tasks/upgrade_postgres.yml @@ -12,6 +12,7 @@ - set_fact: postgres_auto_upgrade_backup_data_path: "{{ matrix_postgres_data_path }}-auto-upgrade-backup" + when: "postgres_auto_upgrade_backup_data_path|default('') == ''" - name: Fail, if trying to upgrade external Postgres database fail: