From bdb2c921bab66cd7627f4c079a13143572e853e1 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 14 Oct 2025 15:39:40 +0000 Subject: [PATCH] docs: Document wal-g restore process. --- docs/production/export-and-import.md | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/production/export-and-import.md b/docs/production/export-and-import.md index c475fa97bc..6df6100c73 100644 --- a/docs/production/export-and-import.md +++ b/docs/production/export-and-import.md @@ -587,6 +587,53 @@ analysis of recent application-level data changes. You may also want to adjust the [incremental backups][incremental] configuration. +### Restoring from wal-g backups + +The following steps will restore the database from the latest +backup. Note that this process will _delete your current database_. + +1. As `root` on your database host, check your list of backups; the + most recent will be listed at the bottom, and is what will be + restored by the commands below. + + ```shell + env-wal-g backup-list --pretty + ``` + +1. Stop Zulip, if it is running. On your application host (which may + or may not be different from your database host, depending on your + configuration): + + ```shell + /home/zulip/deployments/current/scripts/stop-server + ``` + +1. As `root` on your database host, stop PostgreSQL: + + ```shell + service postgresql stop + ``` + +1. As `root` on your database host, delete the current database, and + restore from the backup. This may take some time, depending on the + size of your database and your connection to your backup storage. + + ```shell + pg_version=$(crudini --get /etc/zulip/zulip.conf postgresql version) + rm -rf "/var/lib/postgresql/$pg_version/main" + env-wal-g backup-fetch "/var/lib/postgresql/$pg_version/main" LATEST + chown -R postgres.postgres "/var/lib/postgresql/$pg_version/main" + touch "/var/lib/postgresql/$pg_version/main/recovery.signal" + service postgresql start + ``` + +1. As `root` on your application host, flush caches and start Zulip: + + ```shell + /home/zulip/deployments/current/scripts/setup/flush-memcached + /home/zulip/deployments/current/scripts/start-server + ``` + [wal]: https://www.postgresql.org/docs/current/wal-intro.html [archive-timeout]: https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT [mobile-push]: ../production/mobile-push-notifications.md