Your question
I’m running the latest version of stalwart with RocksDB as a backend storage engine. The documentation says for backup it is enough to back up the directory. However I think the server should be stopped for that to work without problems.
I found an old thread about 2 years ago where it is stated that a backup functionality is planned for stalwart but I didn’t find any updates regarding backups.
RocksDB seems to have it’s now BackupEngine - is that accessible from the stalwart cli?
What’s the best way to backup the stalwart server without shutting it down?
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on
There are two distinct aspects to backup in Stalwart, and the docs cover both:
1. Configuration/settings backup (live, no downtime needed)
The stalwart-cli snapshot command walks the live server and exports all configuration objects (accounts, domains, settings, roles, etc.) to an NDJSON file without stopping the server. This can be used for disaster-recovery and can be restored with stalwart-cli apply:
stalwart-cli snapshot \
Tenant Domain Directory DkimSignature AcmeProvider Certificate DnsServer Role \
Account \
SystemSettings DataRetention BlobStore InMemoryStore SearchStore \
--allow-unresolved PublicKey \
--output "backup-$(date +%Y-%m-%d).ndjson"
This covers configuration and server state, not email message data itself.
2. Data/email backup (the RocksDB directory)
The current docs still state that for embedded stores like RocksDB, the approach is to copy the /var/lib/stalwart directory. The docs do not mention a live/online backup path using RocksDB’s own BackupEngine, and there is no stalwart-cli backup subcommand exposed for that purpose. So for a consistent filesystem-level backup of message data with RocksDB, stopping (or at minimum pausing) the server is the safest approach.
In summary: RocksDB’s BackupEngine is not currently exposed through the CLI. The recommended approach for full data backup is either stopping the server and copying the data directory, or using the snapshot command for configuration-only backups. The docs do not yet describe an online/hot backup path for message data in RocksDB.
Relevant docs:
This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.
Snapshot for server configuration, Vandelay for account backups.
Thanks.
Server configuration backup
The snapshot seems to have some problems:
unexpected server response: no schema available for x:DnsServer
When I remove it from the snapshot I get the error:
Domain references DnsServer but DnsServer is not in the snapshot selection;
(I can add it to --allow-unresolved but I’m not sure if that’s a solution)
Account backups
For Vandelay it seems hat I have to backup every account individually?
I’d post that snapshot up as a separate issue and see if the bot finds a problem in the code.
Yes Vandelay is account by account since it’s not a Stalwart specific tool, but it shouldn’t be too difficult to use the stalwart-cli to get a list of accounts and a wrapper-of-choice to run through exporting them.
It did just launch so there could very well be more QoL switches coming.
Created a follow-up issue regarding the snapshot problem: Stalwart-cli snapshot not working as expected.