For very high volume servers we recommend switching from the default MySQL storage back end to the the Redis back end for Bayes data. This allows spam training and Bayes lookups to run in memory which makes it extremely fast.
Export the Current Bayes Data
Run the sa-learn command below to export the Bayes data that is stored in the MySQL database to a file that you can use later to import back into the Redis database:
sa-learn -u amavis --backup > /tmp/amavis-bayes.db
Install Redis/Valkey
Important: It is up to you to secure your Redis/Valkey installation. You should make sure that the port 6379 is not exposed to the Internet. We recommend binding it to the IPv4 loopback interface 127.0.0.1 (normally this is done by default) and setting a password for it. Also Redis/Valkey is an in memory storage engine so you must have the free memory available on the server. (A typical server will use under 100MB of bayes data while a really busy server could use over 1 GB of memory.)
RHEL/Centos/Cloudlinux/AlmaLinux 10
Note: Because of a license change (non open source), redis was replaced by valkey (an open source fork) in EL-10.
yum install valkey
systemctl enable valkey --now
RHEL/Centos/Cloudlinux/AlmaLinux 9/8/7
yum install redis
systemctl enable redis --now
Debian/Ubuntu
apt-get install redis-server
systemctl enable redis-server --now
Set a Password for Redis
Edit the redis.conf or valkey.conf (if you re using valkey) and find and uncomment the following line changing the password to a new strong password.
# requirepass foobared
Enable Redis/Valkey in Warden
- Go to Warden -> Settings -> Learning Settings and change the Bayes store module option to Redis.
- Enter in the Redis password in the Bayes SQL DSN.
- Enter in the Bayes Token TTL (The number of days before the entries expire). For low volume servers we recommend 180d (6 months). For high volume servers we recommend 90d (3 months).
- Press the update button to save your settings.

If everything is working you should see the Anti-spam learning dashboard widget reset to zero and it should increment throughout the day as the real-time learning, auto learning, and nightly training runs.

Import the Exported Bayes Data Back into Redis
Run the sa-learn command below to import the exported Bayes data back into the Redis database:
sa-learn -u amavis --restore /tmp/amavis-bayes.db