Backing up and restoring a Synapse homeserver

A Synapse backup is only useful if a restore has been tested. This page covers what to back up, how often, which caches to skip and the restore order that keeps encryption and federation identity intact.

On this page

Backing up a Synapse homeserver: what the restore must bring back

A self-hosted Synapse server holds user accounts, room history, encryption-related state and uploaded media, and a failed disk or a bad upgrade must be recoverable without guesswork. A backup of a Synapse homeserver needs four things captured together: the configuration files (including homeserver.yaml), the signing key that identifies the server to other homeservers, the PostgreSQL database, and the media store. A backup missing any one of them can restore a server that starts but cannot read its history, keeps its users locked out of encrypted rooms, or cannot serve files that users uploaded. Only a restore run into a separate environment proves that the set works, so the plan should include a dated restore test, not just a successful backup job.

The backup also serves as your rollback path. The Synapse upgrade notes warn that rolling back can be difficult because database schema changes between releases may not reverse cleanly, so a bad upgrade is usually fixed by restoring the database and files taken before the upgrade, not by downgrading the software. Before each upgrade, take a fresh backup, record the Synapse version and the PostgreSQL version in use, and confirm the restore instructions match that pair. Your PostgreSQL version also has a lifecycle: confirm with the PostgreSQL versioning policy which major release your cluster is on and when it leaves support, because a backup restored onto an unsupported platform adds risk to the recovery itself.

The work described here is planned and carried out in infrastructure you control: your servers, storage, backup targets and retention rules. Decide early where backups are stored, who can read them, how they are encrypted at rest, and how long they are kept, since those choices affect the backup copies of user data and signing keys. Confirm with your own security and data protection teams before the first run, and write the decisions into the runbook so the restore steps reflect the environment that will exist when it is needed.

Which backup components to capture and when each fits

This table compares the five components a Synapse backup may need: the config file, the signing key, the PostgreSQL database, the media store and optional caches or worker configuration. Read each row for what it holds, whether it can be skipped and what you lose without it. The main takeaway is that the signing key, database and media store are the components you cannot rebuild from scratch.

ComponentWhat it holdsCan it be skipped?Consequence of losing it
Homeserver config fileServer name, listeners, database settings, registration and federation options, and the path to the signing keyNo, keep a copy in version control or a secrets storeSynapse will not start as configured, and you must rebuild settings from memory or other copies
Signing keyThe server's private key used to sign events and federation requestsNoThe server identity changes, remote servers will not trust the restored signatures, and federation with existing peers is damaged
PostgreSQL databaseUsers, rooms, events, devices, account data and encryption key backups, with the schema for the installed Synapse releaseNo, it is the primary record of the homeserverMessage history, accounts and room state are lost, and recovery depends on the last usable dump or archive
Media storeUploaded files and cached remote media stored on disk, referenced by the databaseRemote cache may be skipped, local uploads may notUsers lose uploaded files and images, and media links in restored messages return errors
Caches and derived dataCached state and data Synapse can rebuild during operationYes, in most casesSynapse may run slower until caches warm up, with no loss of messages
Worker configurationPer-worker config files and Redis settings for a scaled deploymentNo, if you run workersWorkers may fail to join replication, so the restored server is incomplete until the layout is rebuilt

Setting up a backup and restore sequence with checks

This sequence captures a Synapse homeserver's configuration, signing key, PostgreSQL data and media in a consistent state, then proves on a separate host that the copy starts, keeps its identity and preserves access to encrypted history. Each step ends with a check so the backup is only trusted once a restore has passed.

  1. Inventory files, database and media locations

    The Synapse administrator lists everything that holds server state before any copy is made. This covers the configuration file (homeserver.yaml), the signing key file named in its configuration, any extra config files, the PostgreSQL database, the media store directory, and any worker or Redis settings that define the deployment. Record the server_name, the Synapse version in use, and the PostgreSQL major version, because a restore must match them. The step is done when the list is written down and each item has a named owner and a storage location. Confirm the exact paths in your own environment, since packages, containers and Helm deployments store them differently.

  2. Quiesce writes before capture

    The administrator stops or quiesces Synapse so that the database and the media store describe the same point in time. For a single-process install this means stopping the Synapse service, and for a worker deployment it means stopping every worker and the main process. Keep PostgreSQL running so the dump can be taken. Confirm that no Synapse process remains and that the reverse proxy shows the server as unavailable, which tells you the capture window is clean. Write down the start and end times of the window so it can be matched to the dump file later.

  3. Dump PostgreSQL consistently

    The database administrator takes a logical dump with pg_dump, or a base backup if continuous archiving is already set up for point-in-time recovery. A dump taken from a stopped Synapse gives a consistent snapshot without extra work. Where the database is large or must be recovered to a point between backups, configure continuous archiving and a base backup as described in PostgreSQL's continuous archiving documentation. Store the dump with a checksum and record the PostgreSQL server version it came from. The step is done when the file opens with the matching restore tool and the checksum matches the value recorded at creation.

  4. Copy media, configuration and signing key separately

    The administrator copies the media store, the homeserver configuration and the signing key file to storage that is separate from the server and the database backup. The signing key is the most sensitive item: it identifies the server to other homeservers, so its copy should be encrypted and restricted to the people allowed to restore the server. Keep the configuration and key together with the database dump's metadata so that one restore set is not split across locations. Verify that the media directory copy has the same file count and total size as the source, and that the key file's checksum matches the original. The step ends when each item is in its store and its checksum is logged.

  5. Resume Synapse and confirm the source is healthy

    After the copies are verified, the administrator starts PostgreSQL-dependent services again, then starts Synapse and every worker. The check confirms that the source server returns its normal version response and that a test account can send a message in an existing room. This confirms the capture window did not leave the source in a broken state, which would matter if the backup were ever used to replace it. Record the time Synapse returned to service so it can be compared with the capture window.

  6. Restore to a separate host

    The administrator restores the database, media, configuration and signing key onto an isolated host that matches the source's Synapse version, Python version and PostgreSQL major version. Restoring to a separate host avoids clashing with the live server, which uses the same server_name and signing key. Keep the restored host off the public network and its federation port closed, and change any settings that would send traffic to real external destinations during testing. Confirm that the restore completes without errors and that the database schema loads at the expected version. The step is done when the restore log is clean and the database connects.

  7. Test the restored server with functional checks

    The administrator starts Synapse on the restored host and runs checks in order. The server must start without schema or configuration errors, the server_name in the restored configuration must match the source exactly, and the signing key must load. A test user must log in, and the account must be able to read a room with encrypted history that was created before the backup, using the device keys and key backup available for that account. Confirm that a message sent from the restored host to the test room appears where expected. Any failure at this stage means the backup is not yet proven and the cause should be fixed before the next capture.

  8. Record the proof and schedule the next test

    The administrator writes a short restore record that lists the backup date, the Synapse and PostgreSQL versions, the checksums, the test results and the names of those who ran the restore. The record is stored with the backup set and reviewed when Synapse, PostgreSQL or the host platform changes. Confirm the record can be found without access to the failed host, because the restore is only useful if the person on call can use it. Ask your team to agree how often restore tests run, since that decision should be based on how much data the homeserver holds and how much history users depend on.

Choosing between logical dumps, base backups and point-in-time recovery

A logical dump writes the database contents as SQL or a custom archive that can be replayed into a fresh PostgreSQL instance. It is the simplest approach to understand and to test, and it works across PostgreSQL major versions, which makes it useful as an independent copy before an upgrade. Its weakness is restore time, which grows with the size of the database because indexes and data must be rebuilt. For a homeserver with a modest database, a nightly dump is often a reasonable starting point, but the team should measure how long a full restore takes on comparable hardware before relying on it.

  • Consistency: pg_dump takes a consistent snapshot of one database at the time it starts, so Synapse should be stopped or quiesced if you need the dump to match the media store and config taken at the same moment.
  • Restore time: Expect the restore to be the slowest step on large databases because data is loaded and indexes are rebuilt.
  • Features used: Standard SQL export with MVCC snapshots; no WAL archiving or replication setup is needed.
  • Recovery point: The recovery point is only as recent as the last dump, so events written after it are lost.
  • Cost driver: Storage for dump files and the time the backup window occupies on the database host.

Before you rely on dumps, confirm the restore procedure end to end on a separate host and record the elapsed time for your own data volume.

How the backup components fit together during a restore

The restore starts from backup sets that were written off the source host to separate storage, and those sets hold the config, the signing key, the PostgreSQL dump and the media store. The restore host rebuilds PostgreSQL and media first, then config and key, and only then starts Synapse. Verification comes last: a login, a look at room history and a check that encrypted messages still decrypt. Any failure there sends you back to the backup set, not to the running server.

Restore order runs from backup sets through database, media and config to Synapse checks.

Caches and derived data you can usually skip

Synapse keeps several kinds of data that can be rebuilt, re-fetched or regenerated after a restore. Skipping them shrinks the backup, but only when you have confirmed the exclusion against the Synapse documentation for your release. The items below are where teams most often make a wrong assumption, especially around media and Redis.

Cached remote media

Media that Synapse downloaded from other servers is a cache, so it can usually be re-fetched when a user opens it again. Local uploads are different: they exist only on your server and belong in the media backup. Before excluding remote media, confirm in the current Synapse documentation how the media store separates local and remote files on your version. Also agree with your users that remote files may load more slowly or disappear from other servers before the restore.

Synapse docs

Redis replication state

Redis relays replication traffic between the main process and workers. It holds live coordination state rather than the durable record of rooms and users, so a restore normally starts with an empty Redis instance. Check the workers documentation for your deployment before assuming this, and confirm that a cold Redis start leaves no data that only exists there. Restart the main process and all workers after the restore so they reconnect cleanly.

Workers docs

Temporary and runtime files

Working directories, sockets, process ID files and log output are created at startup or during operation. They do not hold account or room data, and a restored host recreates them. Exclude them from the backup set, but confirm the paths against your installation, since a packaged or containerized install may place them in different locations. Logs can be kept separately if your retention policy requires them.

Derived state compression output

Tables produced by state compression or other maintenance jobs are regenerated from existing data, so they are not a second source of truth. Restoring the database from a consistent dump already includes them. Do not treat a partial copy of these tables as a backup. Confirm with the upgrade and maintenance notes for your release before dropping or rebuilding any derived table by hand.

Search indexes and sync caches

Full-text indexes and in-memory sync caches are rebuilt by Synapse when it runs, so they rarely need separate backups. Restore the PostgreSQL dump with its indexes and let Synapse warm caches after startup. Plan for slower first requests after a restore. Do not exclude anything from PostgreSQL itself on the assumption that it is a cache, because indexes and tables travel together in a dump.

Upgrade notes

Restore steps that keep encryption and federation identity working

A restored Synapse homeserver must present the same identity it had before the failure. The signing key and the server_name value are the two pieces that establish this. Other servers verify events and requests against the signing key published for your server name, and every user ID and room ID embeds that name. If you restore the database with a freshly generated signing key, remote servers will reject signatures on events your server sends, and history your server already federated will no longer match the key it now claims. If server_name differs from the original, existing accounts and rooms become unreachable under their old IDs. Both values must be copied from the original homeserver.yaml and signing key file before the first start, not regenerated during a rebuild.

A restore that loads the PostgreSQL dump without the matching media store or key files can start and still misbehave. Users may see broken attachments, rooms may fail to validate old events, and some clients may hit errors only when they open a particular conversation. Treat the database, the media directory, the signing key and the config as one set taken at the same point in time, and check that the media path in the config points at the restored files. Encrypted message keys are held on the client side, so the server restore does not recover them, but a mismatched server identity can make devices appear to lose trust in ongoing sessions. Confirm this with a test account and an encrypted room before you announce the restore complete.

Restore to the same Synapse release and the same PostgreSQL major version wherever possible. Synapse upgrade notes warn that rolling back can be difficult because of schema changes between releases, so a backup taken on a newer release cannot be safely loaded onto an older one. Version floors also limit your options: Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer. If the target platform is older than the floor, you must upgrade the platform first, or choose an older Synapse release that matches it. Confirm the exact release recorded in the backup manifest and the PostgreSQL version of the source cluster before you pick the restore host, and check the Synapse upgrade notes for the release you plan to run.

Protecting backups, keys and restored data

A Synapse backup holds the same sensitive data as the live server: account records, room state, message history and uploaded media, plus the signing key that identifies the server to other homeservers. The cards below cover the controls that keep those copies protected, how deletion requests reach backups, and how restore access is recorded.

Encrypt backup archives at rest

Every archive of the configuration, PostgreSQL dump and media store should be encrypted before it leaves the database host. Choose the key management approach with your security team, store the decryption keys apart from the backups they open, and test that a restore works with only the keys held by the people authorized to recover data. Confirm whether your encryption meets the standards your organization follows, because the answer depends on your environment.

Limit who can reach backup storage

Backup buckets, tape sets and snapshot repositories often have looser access rules than the production server. Grant read and write access to a small named group, separate the account that writes backups from the account that restores them, and block public listing. Review these grants on the same schedule as admin access to the homeserver itself.

Protect the signing key and config secrets

The homeserver signing key and the secrets in homeserver.yaml, such as the registration shared secret and database password, need the same care as the database. If a copy of the signing key is exposed, another party can impersonate your server. Store these files in a secrets manager, restrict file permissions, and record where each copy is kept so you can rotate it after an incident.

Apply deletion requests to backups

When a user asks for erasure, the live database and media store change, but older backups still hold the data until they expire. Decide with your legal and compliance teams how long backups are kept, whether deleted data must be purged from them, and how a restore re-applies erasures made after the backup was taken. Ask the compliance team to confirm the position before you set retention periods.

Record and review restore access

A restore copies the most sensitive data the server holds, so each restore should have a ticket, a named operator and a log of the commands run. Keep audit records of who opened backup archives and who ran restore steps, and store them outside the homeserver. Review these records after each restore drill and any real recovery, and confirm with your auditors which log retention they expect.

Common questions about Synapse backup and restore

How often should I back up a Synapse homeserver?

Back up the PostgreSQL database and the signing key on a schedule that matches how much chat history you can afford to lose, and confirm the interval with your own recovery targets rather than a fixed rule. The config files and the signing key change rarely, so they can be copied on each change. The database and media store change constantly, so they need a recurring job. Before any Synapse upgrade, take a fresh backup, because the upgrade notes warn that rolling back can be difficult because of database schema changes between releases. Point-in-time recovery of PostgreSQL, documented in the PostgreSQL continuous archiving guide, lets you narrow the gap between the last base backup and the failure.

Can our own team back up and restore Synapse without a partner?

Yes, if your team already runs PostgreSQL and Linux services and can follow the upstream documentation closely. The work is mostly standard database and file operations plus a few Synapse specifics: keeping the signing_key_path file, the homeserver.yaml configuration and the media store together, and knowing which caches can be skipped. The hard part is proving the restore works, which needs a separate environment, a timed test and a checklist that someone other than the author can run. Teams without that routine usually find the first restore is the first real test. A partner is most useful when you want that test designed, documented and handed over.

What do we need to provide before a backup and restore engagement starts?

You need to provide access and information that the work depends on. Expect to supply the Synapse version and deployment method, the PostgreSQL version and hosting model, where the signing key and media store live, the backup tooling and storage you already use, and the recovery expectations your business has set. You also need a non-production environment that can hold a copy of the database and media for restore tests, plus named owners who can approve changes to production. Confirm whether Synapse runs on a single host, with workers, or on Kubernetes, because that changes which volumes and services must be captured.

How do we prove that a Synapse restore actually works?

A restore is proven when a separate environment, built from the backup alone, starts Synapse, serves existing rooms and media, and lets a known test user sign in and read messages that were sent before the backup. Record the steps, the time taken and any errors, then compare the restored data with a known point in the source. Check that end-to-end encrypted rooms still decrypt on a device that has its keys, because encryption depends on the signing key and the stored key material being restored together. Repeat the test on a schedule, and after each Synapse or PostgreSQL upgrade, since a backup that restored last year may not restore on newer versions.

What makes backup and restore effort go up or down?

The main drivers are the size of the PostgreSQL database and media store, how many components run (workers, Redis, reverse proxy, MAS, bridges), and how your platform handles backup, storage and retention. Restore time grows with data volume, so large media stores and years of room history will take longer to copy and verify. Multi-host or Kubernetes layouts add volumes and secrets to capture in the right order. Compliance requirements for retention, encryption of backups and access logging add work. A simple single host with a managed backup tool and a documented restore path costs less to design and test than a layout with several stateful services.

What should we ask for in a fixed-scope quote for this work?

Ask for a written scope that names each item to be backed up, the restore environment to be used, and the acceptance test that counts as a successful restore. The quote should list deliverables such as the backup configuration, a restore runbook, a timed restore test report and a handover session, and state which of these run once and which recur, such as scheduled restore tests after upgrades. Ask which Synapse and PostgreSQL versions are covered, what is excluded (for example media retention policy decisions or application-level recovery of individual rooms), and what the client must provide before work starts. Fixed-scope engagements are agreed in writing before work begins, so the scope and timeline should be explicit in that document.

Do we have to upgrade PostgreSQL before we can back up Synapse?

No, backups do not require an upgrade, but the PostgreSQL version decides which restore paths you can use and how long you have before support ends. Supported PostgreSQL versions include 14 through 18 according to the versioning policy, and Synapse 1.143.0 and later require PostgreSQL 14 or newer. A dump restored into a different major version needs a planned migration, and minor releases only replace executables and need a restart. If your current version is near the end of its support window, plan the upgrade and a restore test together, so you do not test a backup on a platform you are about to retire.

How DeployOpen scopes and delivers Synapse backup and restore

DeployOpen plans, builds and documents backup and restore for a Synapse homeserver running in infrastructure you control. The work covers the configuration, signing key, PostgreSQL database and media store, and ends with a restore your team has actually rehearsed.

How we scope

  • Inventory the config files, signing key, PostgreSQL database, media store and any worker or Redis state the homeserver depends on.
  • Agree in writing which items are backed up, how often, where copies are kept and who owns each step.
  • Confirm the Synapse and PostgreSQL versions in use, since restore steps depend on them, and record what must be verified before work starts.

How we build

  • Configure scheduled PostgreSQL and media backups with retention settings that match the scope agreed with your team.
  • Document which caches can be skipped and which files must be kept so encryption keeps working after a restore.
  • Run test restores into an isolated environment and record the results, timings and any gaps found during each test.

How we hand over

  • Deliver a written restore runbook covering the exact order of steps, the commands used and the checks that confirm a healthy server.
  • Provide the backup schedule, retention policy and the list of secrets and files that must be stored separately from the backups.
  • Walk your operations team through a restore drill so they can run the procedure without DeployOpen present.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous restore testing are available as a retainer after handover.
  • Ask any partner to confirm how backups are reviewed when Synapse or PostgreSQL versions change.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.