Mattermost backup and restore

A Mattermost restore needs the PostgreSQL database, the config directory with SAML certificates and the file store together, taken from a stopped server. This page explains what to back up, how to plan it and what to confirm before you rely on it.

On this page

Mattermost backup and restore: what a restore actually needs

If you run self-hosted Mattermost, a usable backup is three things captured together: the PostgreSQL database, the config directory and the file store. A database dump alone cannot restore a working server, because channels, posts and metadata live in PostgreSQL while the config.json file holds settings such as SAML certificate paths and connection details, and uploaded files sit on local disk or in an S3 bucket. Mattermost runs as a single Linux binary on PostgreSQL, so the server itself is easy to rebuild from a release. The data around it is what you must protect, and the restore is only as good as the three copies taken at the same point in time.

Write a backup plan once the deployment is more than a pilot: when one server carries daily work, when the user base is growing, or when chat content falls under retention, legal hold or records obligations. The plan should name who takes each backup, where it is stored, how long it is kept, and who is authorized to restore it. Confirm with your Mattermost team which config settings reference files outside the config directory, such as SAML certificate locations, and confirm which file storage backend your server uses. Those answers determine which paths and buckets belong in the backup set.

A backup is only trustworthy if the pieces match. Mattermost documents stopping the server before a clean backup, because posts and file records that change during a dump can leave the database pointing at files that were not copied, or the reverse. Plan a maintenance window for the database dump and file copy, and check it against your own user hours. Then test a restore on a separate host, starting the server and confirming that messages, attachments and SAML sign-in all work before you rely on the backup. Treat the restore test as a recurring control, not a one-time check, and record the result each time.

Which four components Mattermost restore depends on

A Mattermost restore depends on four parts that must be captured together: the PostgreSQL database, the configuration and SAML certificates, the file storage, and any search or cache services. Each holds a different kind of state, so a backup of one part does not restore the server. Capture them from the same stopped point so the database, files and configuration agree.

PostgreSQL database

PostgreSQL holds the messages, channels, users, teams and most settings that make up a Mattermost server. Mattermost runs on PostgreSQL as its database, so the database backup must match the file storage taken at the same moment. If the database is missing, message history cannot be rebuilt from anything else. Confirm that your backup method produces a consistent copy, and test a restore into a separate environment before you rely on it. Back up the database from the same stopped state as the files.

PostgreSQL archiving docs

Config directory and SAML certificates

The config directory holds the server configuration file and any SAML certificates used for single sign-on. Without the configuration, the restored server may start with different settings or without the customizations you made. SAML certificates tie logins to your identity provider, so a restore without them can leave users unable to sign in. Confirm that the identity provider still trusts the restored certificates, and store copies with the same access controls as the database. Losing the certificates breaks sign-in, not just settings.

Mattermost SAML docs

Local file storage or S3 bucket

Uploaded files are stored outside the database, so a database restore alone returns messages that point to files that no longer exist. With local storage, back up the file directory at the same point as the database. A high availability cluster needs shared storage, such as an Amazon S3 bucket, an S3-compatible service or NAS mounted on each node, because local file system storage will not work correctly and risks corrupting files. Confirm the storage type and its retention settings in your environment. A database restored without its files leaves broken attachments.

Mattermost HA docs

Search and cache services

Search indexes and external caches are derived data, but they are still part of the running system. Mattermost supports database read replicas and search replicas, and larger deployments may add an external cache, so list each service that your deployment uses. Confirm whether each one can be rebuilt from the database or must be restored from its own backup, and how long a rebuild would take on your message history. Record an owner for each service. Search and cache services left out of the plan extend the restore window.

Why a clean Mattermost backup needs the server stopped

A clean backup needs Mattermost stopped because the database and the file store are separate copies that can describe different moments. The PostgreSQL dump captures posts, channel membership and file metadata as they stood when the dump began. A file copy of local storage or an S3 bucket taken at another time may hold attachments uploaded after that point, or lose attachments that a later post still references. Either way, a restored server can show posts whose files are missing, or files with no post that points to them. Taking the two copies while the server keeps writing makes that mismatch likely on a busy system, and the gap grows with the length of the copy.

Stopping the server removes that trade-off. With no writes during the window, the database dump and the file copy describe the same state, and the cost is downtime for users while the backup runs. Plan that window with the business owners before the first run, because its length depends on database size and on how much file data must be copied, and both grow over time. The config directory, which holds the SAML certificates and other settings a restore depends on, should be captured in the same window so it matches the database and files. Confirm the exact stop, dump and copy steps against the current Mattermost and PostgreSQL documentation for your version and storage type before you schedule the first backup.

Close the window only after the backup is verified. Restore the backup to a separate test environment, start Mattermost there, and check that a sample of recent posts opens with their attachments, that users can sign in through the configured identity provider, and that the file count and database record count are consistent with the source. Record the backup time, the Mattermost version and the checksums in the runbook. If the test restore fails, the production server should not be left in a state where the only available copy is unverified. Ask your DeployOpen team or your own operators to confirm the verification steps against the restore procedure in your environment.

Backup approaches and when each fits

A single Mattermost server with files on its local disk is the simplest environment to back up, because the database, the config directory and the file directory all live on one host. A consistent backup means copying all three while Mattermost is stopped, so no user writes land between the database capture and the file capture. Local storage is also the least resilient option: a disk failure takes the files and the backup copy together unless backups are written to a separate system.

  • Scope of the copy: the PostgreSQL database, the config directory (including SAML certificates and the configuration file) and the local file directory must be captured together.
  • Stop before copying: plan a maintenance window so the database and files reflect the same moment.
  • Separate target: write backups to a different host, volume or storage account so a single failure cannot remove both the data and its copy.
  • Restore test: a backup that has never been restored onto a clean server is unproven, so schedule a restore into a separate environment.
  • Retention and encryption: confirm how long copies are kept and how they are encrypted at rest.

Confirm with your platform team which backup agent, snapshot tooling or scheduler your servers already run before adding a new tool.

Backup components, tools and trade-offs

This table lists each component a Mattermost restore depends on, how often it changes, how to capture it and the main trade-off of each method. Read it as a checklist: a backup that misses any row can restore a server that starts but loses messages, files or sign-in.

ComponentWhat changes and how oftenHow it is capturedMain trade-off
PostgreSQL databaseEvery post, channel, user and setting; changes continuously while the server runsLogical or physical dump, plus continuous WAL archiving for point-in-time recovery (see PostgreSQL point-in-time recovery docs)A dump is simple but captures one moment; archiving adds recovery granularity and more storage and setup to maintain
Config directory and SAML certificatesChanges rarely, mainly on settings changes and certificate renewalFile copy of the config file and the certificate and key files it references, stored with restricted permissionsFew bytes but high sensitivity; copies must be encrypted, and a stale copy can break SAML sign-in after renewal
Local file storageGrows with every upload; changes between backupsFile-level copy or snapshot of the data directory taken while the server is stoppedConsistent with the database only if taken in the same stopped window; large volumes lengthen downtime
S3 or S3-compatible file storageGrows with every upload; objects are added and sometimes removedBucket versioning, cross-region replication or a separate sync to a backup bucketProtects against bucket loss but not against accidental deletion unless versioning or object lock is set; confirm with your storage vendor
Search indexes (if used)Follow database content; rebuilt from postsUsually not backed up; re-index from the database after restore, or snapshot the search cluster if your search platform supports itRe-indexing saves storage but takes time after a restore; confirm the procedure for your search service
Plugins and custom integrationsChange on install, update and removalCopy the plugin directory and record installed versionsPlugin files alone may not match the database state; restore to the same server version and test

How to set up a repeatable Mattermost backup and restore

This sequence produces a backup set that is complete, consistent and proven to restore on a separate host, so recovery does not depend on memory or on one server.

  1. Inventory components and assign owners

    List everything a Mattermost restore needs: the PostgreSQL database, the config directory including SAML certificates and any key material, file storage (local disk, NAS or S3 bucket), and any plugin or proxy configuration kept outside the server. For each item, name an owner who approves changes to it and who runs the backup. Confirm the storage locations against the live config.json and your deployment records, not against the original install notes. Done when every component has a location, an owner and a note on where its restore instructions live.

  2. Choose storage targets and retention

    Pick an off-server target for copies, such as a separate backup host, a NAS or an object store, and confirm that it is access-controlled and encrypted in transit and at rest under your own policy. Set a retention rule that your records and legal teams have approved, and decide how many generations you keep so an older copy survives if the newest one is corrupted. Ask your database and storage vendors to confirm the supported backup methods for your versions. Done when the target, the retention rule and the access list are written down and approved.

  3. Schedule the stop and capture window

    Plan a window in which Mattermost is stopped so that the database, configuration and files are captured while no writes occur. A running server can change posts, files and sessions during the copy, which produces a set that does not match itself. Notify users, confirm the window with the business owner, and agree who may extend it if a capture runs long. Done when the window is on the change calendar and the on-call contact knows how to stop and start the service.

  4. Capture database, config and files as one set

    With the server stopped, dump the PostgreSQL database in a format your restore process supports, copy the config directory with its SAML certificates and keys, and copy local file storage or confirm the S3 bucket state. Label all three artifacts with the same backup identifier and timestamp so they can be matched later. Record checksums for each artifact. Done when the three artifacts share one identifier, the checksums are written next to them, and the Mattermost service is restarted and answers its health check.

  5. Record the Mattermost and PostgreSQL versions

    Write the exact Mattermost server version and the PostgreSQL major and minor version into the backup manifest, alongside the backup identifier and checksums. A restore must use a Mattermost build that can read the database schema, and PostgreSQL restores depend on matching major versions for the dump format you chose. Check the version against the Mattermost server releases page and the PostgreSQL versioning policy before relying on it. Done when the manifest lists both versions and the restore runbook names the same versions.

  6. Store copies off the server

    Move the complete backup set to the off-server target chosen earlier, then verify each copy by comparing checksums on the destination. Keep at least one copy outside the network segment that hosts Mattermost so a compromise or failed disk on the production host does not remove every copy. Check that the access list on the target matches the approved list. Done when the destination checksums match the source, and the manifest records where each copy is stored.

  7. Rehearse a restore on a separate host

    Restore the database, config and files onto a separate host running the recorded Mattermost and PostgreSQL versions, then start the instance. Confirm that the database loads without errors, that the restored instance logs in with a test account, that a known channel and file are present, and that SSO still works with the restored certificates. Record the time the rehearsal took and the problems found, then update the runbook. Done when a test user signs in on the restored host and the rehearsal record is filed with the backup manifest.

How the backup set is captured and restored

The capture starts with stopping the Mattermost server so the database, config directory and file store describe the same moment. The PostgreSQL database, the config directory holding SAML certificates, and the file store (local disk or S3) are then captured and moved to off-server storage. The restore path copies the set onto a new host, runs a version check against the Mattermost build, and only then lets users back in. Confirm each step against your own environment and your Mattermost version before relying on it.

Backup set captured while the server is stopped, then restored and checked before users return.

Protecting backups that hold chat history and secrets

A Mattermost backup bundles chat history, uploaded files, and the config directory, which holds SAML certificates and other secrets. The controls below apply to every copy, from the database dump to the object storage bucket, and each one should be matched to your own retention, legal hold and records policies.

Encrypt backup copies at rest

Every copy of the PostgreSQL dump, the config directory and the file store should be encrypted where it sits, whether on a backup server, NAS or object storage bucket. Confirm whether your storage platform encrypts by default, who holds the keys, and whether keys are kept apart from the backups they protect. A backup that is readable without the key exposes the same chat history as the live server.

Encrypt backup transfers in transit

Backups are usually copied across a network to a backup host, a second site or a cloud bucket. Use TLS or an equivalent encrypted channel for each hop, and confirm that tools such as the S3 client or a remote copy job refuse unencrypted endpoints. Check the certificate trust chain on backup targets too, since a backup sent to the wrong host is a disclosure even when it is encrypted.

Restrict access to the config directory

The Mattermost config directory holds the server configuration, and with it the SAML certificates and other secrets such as database credentials and storage keys. Limit read access on the directory and its backup copies to the few administrators who perform restores, and remove access for accounts that only run backups. Treat a copy of this directory as a copy of the credentials, and rotate them when access is no longer justified.

Separate backup operator and restore roles

The account that writes backups does not need to read them, and the people who restore data may not need the live server access. Define who may take a backup, who may read one and who may start a restore, and enforce it on the backup host and the bucket policy. Record each role in your access review so that a departing administrator loses restore rights as well as console access.

Set retention to match legal hold

Backup retention and chat retention are separate settings, and a backup can keep messages that a retention policy or legal hold asks you to delete. Decide how long each backup set lives, how legal hold interacts with rotation, and how deleted content is removed from backups on a schedule your counsel approves. Ask legal and records owners to sign off on the rules before the first backup job runs.

Log every backup read and restore

Record who created, copied, downloaded and restored each backup, when it happened, and which backup set was used. Keep these logs on a system that backup administrators cannot edit, so the record of a restore survives the restore itself. Confirm with your security team which events your backup tool, object storage and Mattermost audit logs can produce, and forward them to your central log store.

Questions buyers ask about Mattermost backup and restore

What does Mattermost backup and restore cost, and what drives the effort?

The cost depends on how much of the backup work is already in place and how many storage locations must be captured together. The main effort drivers are the size of the PostgreSQL database, where file storage lives (local disk, NAS or S3), whether SAML certificates and the config directory are backed up alongside them, and how many environments need the same routine. Mattermost does not publish backup pricing, and DeployOpen does not publish a price list, so a quote follows from a written scope. Ask for the components covered, the storage and retention assumptions, the restore test included, and which items recur, such as scheduled backup checks and periodic restore tests, versus one-time design and setup.

How long does a Mattermost restore take?

Restore time is set by data volume and the order of steps, not by a fixed figure. The database must be restored first, then the config directory must match the backup, then file storage must be put back where the server expects it, and only then can the server start and be checked. Large file stores on S3 or NAS can take longer than the database alone, and a restore onto new hardware adds time for installing the matching server version and the PostgreSQL version it was built against. Run a timed restore into a separate environment to get a real number for your data, and record that figure in the runbook.

What does the client team need to provide for a backup project?

The client team needs to supply access and decisions that only it can make. Typical inputs include the deployment layout (where the Mattermost binary, config directory, PostgreSQL server and file storage run), the storage locations and credentials for any S3 bucket or NAS mount, the retention period the business requires, and the owner of the SAML certificates and signing keys. The team also needs a maintenance window in which Mattermost can be stopped for a consistent backup, and a named person to approve the restore test environment. Confirm these items in the scoping call, because missing access is the most common reason a restore test is delayed.

Can our in-house team set up Mattermost backups without a partner?

Yes, a capable platform or database team can build Mattermost backups in-house if it has PostgreSQL administration skills, access to the config directory and file storage, and time to test. The work is not large in concept, but it is easy to get wrong in the details: the database and file store must be captured at the same point, SAML certificates must be included, and the restore must be proven rather than assumed. Decide between in-house and a partner by asking who will own the restore test, who will be on call when a restore is needed, and whether that person has restored a Mattermost instance before. A written scope from DeployOpen can cover the design, build, and first restore test, and ongoing testing is available as a retainer.

How often should we test a Mattermost restore?

Test restores on a fixed schedule, and also after any change that affects the database version, the server version, storage location, or the config directory. The right interval depends on how much data would be lost if the backup failed, the rate of change on the server, and what your compliance and records requirements set. Each test should restore into a separate environment, start the server, confirm that users can sign in with SAML or your chosen identity provider, check that posts and files open, and record how long each step took. Keep a log of results so auditors and internal reviewers can see the test history.

Does a Mattermost backup require downtime?

A clean backup of Mattermost requires the server to be stopped, because the database and the file store must describe the same moment in time. If Mattermost keeps writing while the database is dumped and files are copied, the two can disagree, so a restore may reference files that were not captured or miss posts that point to them. The length of the stop depends on how long the database dump and file copy take, which depends on data size and storage speed. Some teams reduce the window with storage snapshots or PostgreSQL continuous archiving, but these approaches still need to be tested against a real restore before you rely on them. Confirm the approach with Mattermost's backup documentation for your version and with your own environment.

Which PostgreSQL version should the backup and restore plan assume?

Plan around the PostgreSQL version your Mattermost server uses and the versions still supported at the time of the restore. PostgreSQL supports version 14 until November 12, 2026, version 15 until November 11, 2027, version 16 until November 9, 2028, version 17 until November 8, 2029, and version 18 until November 14, 2030. Restoring a dump into a different major version requires care, because a logical dump and restore or pg_upgrade step is needed. Record the PostgreSQL major version in the backup metadata, and check the PostgreSQL versioning policy when you plan major upgrades so that backups stay restorable on the version you run.

How DeployOpen scopes and delivers Mattermost backup and restore

DeployOpen starts every Mattermost backup and restore engagement with a fixed scope agreed in writing before any work begins. The scope names the components in the backup set: the PostgreSQL database, the configuration directory that holds the SAML certificates and other secrets, the file storage (local disk, NAS or S3 buckets), and the deployment files around the server. It also records who owns each component, how often each one is backed up, where copies are kept, and who is allowed to run a restore. Because the quote follows from this written scope, the client knows exactly what is included before it commits, and the document becomes the reference for later reviews.

The delivery produces two artifacts. The first is an inventory of the live environment: server version, PostgreSQL version, storage mounts, file paths in config.json, and any encryption or certificate material that a restored server would need. The second is a runbook that walks an operator through a restore step by step, including the requirement to stop Mattermost before taking a clean backup and to start it only after the database and files are verified as matching. DeployOpen then rehearses a full restore inside the client's own infrastructure, on an isolated host, and records the time taken and any gaps found. Clients should confirm that their cloud accounts, data centers or air-gapped networks can host that rehearsal environment and that the restore target has the same Mattermost version as the backup.

Restores tend to break after the first rehearsal, because Mattermost releases change, database versions age and storage paths drift. DeployOpen offers optional retainers that cover scheduled restore tests, backup monitoring, and planned upgrades of the server and PostgreSQL, so the runbook stays accurate between releases. Ask any provider, including DeployOpen, to state in the quote what recurs, what is one-time, and who performs each restore test. For the upgrade side, confirm the current support dates with the Mattermost server releases page before you agree a retainer schedule.

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.