Your question
What is the safest way to backup the rocksdb database?
The official guidance is straightforward: stop Stalwart, then copy the entire /var/lib/stalwart directory. That directory contains the RocksDB data files along with blob storage and configuration, so copying it whole is a complete, consistent backup.
A few practical points:
--export / --import commands in the Stalwart binary can do a full database dump/restore, and those also require the server to be stopped.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.
Cleanest path: stop the server, rsync (or filesystem-snapshot) the
directory that storage.data points at, restart. RocksDB is consistent on
shutdown; this is the supported recipe.
A per-account import/export tool will be released in the next few weeks and it will allow you to backup entire accounts without downtime.