Citadel Server's Pluggable Storage Architecture
A frequent question from system administrators and developers is how Citadel stores its data, and whether external relational databases (such as MariaDB, MySQL, or PostgreSQL) can be used. Citadel takes a deliberate, high-performance approach to data storage.
Citadel Server is built around a powerful, modular pluggable data store architecture. Rather than introducing the overhead, network latency, and complex administrative maintenance of an external SQL server, Citadel uses embedded, high-throughput NoSQL engines that live directly within the server process. This design delivers blistering performance, instant zero-configuration deployment, and rock-solid data integrity.
Supported Storage Backends
Citadel's clean storage abstraction layer currently supports two robust backends:
- LMDB (Lightning Memory-Mapped Database, default):
LMDB is the default storage engine for modern Citadel installations. Widely regarded as one of the fastest and most efficient embedded key-value stores in existence, LMDB uses copy-on-write B-trees to provide fully ACID-compliant transactions with lock-free, zero-copy read operations. It scales gracefully to tens of terabytes, handles extreme concurrent loads effortlessly, and is immune to database corruption even in the event of unexpected system crashes.
- Berkeley DB (BDB):
Berkeley DB is a battle-tested, industrial-strength database engine that has reliably powered Citadel installations for decades. It remains fully supported to provide seamless continuity and backward compatibility for existing deployments.
Accessing Messages and Data Programmatically
Because Citadel is designed with a clean domain model, applications and scripts do not need to construct raw SQL queries against internal tables. Instead, Citadel exposes rich, standardized interfaces and protocols:
- Citadel Protocol: A fast, bidirectional API for interacting with rooms, messages, users, and administrative tasks.
- Standard Internet Protocols: Full support for IMAP, CalDAV, CardDAV, and SMTP, allowing any standard client, library, or language to integrate smoothly with your data.
Backing Up Your Data
The recommended best practice for backing up a Citadel server is taking filesystem snapshots:
- Modern volume managers and filesystems (such as ZFS, Btrfs, or LVM) allow you to take instant, point-in-time read-only snapshots of the Citadel data directory.
- Because LMDB relies on copy-on-write transactions, a filesystem snapshot captures a perfectly consistent, uncorrupted database state instantaneously without service interruptions, lock contention, or downtime.
- For disaster recovery or cross-architecture migrations (such as moving between different CPU architectures), Citadel also provides architecture-neutral data export and import tools.