Installing Stalwart to use existing database

Your question

If I want to reinstall Stalwart, how do I get it to use an existing database?

The simplest approach depends on what type of database backend you’re using:

If you’re using an embedded backend (RocksDB/SQLite): Just point your new Stalwart installation at the same data directory. During setup, configure the storage paths to match the existing database location, and Stalwart will pick up the data as-is. No import/export needed.

If you need to move data between different backends (e.g. from RocksDB on the old install to PostgreSQL on the new one), use the built-in export/import utility:

  1. Stop the old Stalwart instance first (required for data integrity).
  2. Export from the old installation:
    /opt/stalwart/bin/stalwart --config /path/to/old/config.json --export /path/to/export-dir
    
  3. Install and configure the new Stalwart instance pointing to your desired backend.
  4. Stop the new instance, then import:
    /opt/stalwart/bin/stalwart --config /path/to/new/config.json --import /path/to/export-dir
    

A couple of important notes:

  • The server must be stopped before running any export or import – running these while the server is live can cause data corruption.
  • The import tool restores all subspaces in the dump; you cannot selectively import, only selectively export (using the EXPORT_TYPES env var).

More details are in the Database Migration docs.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

When restoring a database, the documentation mentions a config.json, form where is this file obtained?

URL documentation : Stalwart doc : Configuration file

Could you please review the documentation? The site’s search function is very well designed. Depending on whether you have an older or newer installation, this file may be located in different places. Config.json is no longer used in version 0.16, so please specify your requirements. For now, we understand this to mean “use the same database for a new Stalwart installation.”

If we assume you’ll be using the same version of Stalwart—let’s say 0.15—then you should use the same `config.json` file, which will likely contain your SECRET for the database.

As you can see, I can only make assumptions since you’ve provided very little or no information.

Thank you (again). I was reading Database Migration | Stalwart . Since 0.16.x does not use a configuration file and there was no mention of what what this file is or where to find it on the linked page, this was very confusing to me. I do sincerely apologise for my inexperience.