Skip to main content

Data store

In Stalwart Mail Server, the data store is where e-mail metadata, folders, settings, and most data is kept. It is important to note that the data store does not hold email messages, sieve scripts, or other large binary files. These are managed separately by the blob store to optimize performance and manageability.

The following database backends can be utilized as a data store:

  • RocksDB: A high performance embedded database for key-value data (recommended for single node installations).
  • FoundationDB: A distributed database designed to handle large volumes of data across clusters of machines (recommended for multi-node installations).
  • PostgreSQL: A powerful, open-source object-relational database system.
  • MySQL: An open-source relational database management system.
  • SQLite: A C library that provides a lightweight disk-based database.

Due to their performance and scalability, RocksDB is the recommended backend for single node installations, while FoundationDB is recommended for multi-node installations.

Configuration

To configure the data store, you need to specify the ID of the store you wish to use under the storage.data attribute in the configuration file. For example, to use the rocksdb store as the data store:

[storage]
data = "rocksdb"

Maintenance

In order ensure efficient use of storage and optimal database operations, Stalwart Mail Server runs periodically automated tasks that perform essential maintenance such as removing expired entries or compacting logs. The schedule for these tasks is configured using a simplified cron-like syntax. The frequency of these tasks is determined by the store.<id>.purge.frequency attribute of the configuration file, where <id> is the ID of the store you wish to configure.

For example, to run the job every day at 3am local time on the foundationdb store, you would add the following to your configuration file:

[store."foundationdb".purge]
frequency = "0 3 *"