Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

docs: Document wal-g restore process.

Alex Vandiverbdb2c921bab6
diff --git a/docs/production/export-and-import.md b/docs/production/export-and-import.md
index c475fa97bc2..6df6100c730 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