Problem with spamassassin migration

Discussion in 'Installation/Configuration' started by mikolaj_koziej, Jul 3, 2019.

  1. mikolaj_koziej

    mikolaj_koziej New Member

    I have a problem with db bayes migration.
    I execute:
    sa-learn --backup > file.txt
    sa-learn --restore=file.txt
    Unfortunately, bayes on new server does not work. In the logs I have information that the plugin is loading, but it can not be evaluated because there is too little spam. It's 62 and you should be at least 200. But that it works on the old server.
    On the old server, how do I run:
    spamassassin -t /path/to/mail
    it also does not start the bayes. But when I check the headers in the mailbox, this bayes was running.
    It seems to me that spamassassin is run by another user and the config is loaded from a different place. Whence? How to transfer it? Does every user have their own config? Please help.
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    In ISPConfig, spamassassin is run from amavisd as the amavis user; if you run any spamassassin commands on the cli (sa-learn, etc.) you need to run them as 'amavis'. As far as spamassassin config, most of it is in files under /etc/spamassassin/, with some related amavis settings under /etc/amavis/ and a few settings (for amavis, not spamassassin as ISPConfig configures it) stored in the database.

    How to transfer old bayes data? Or your spamassassin config? For bayes, dump your old db like you did, copy it to a file that the amavis user can read (eg. put it under /tmp maybe, and check permissions), then load it as the 'amavis' user, eg. something like
    cd /tmp
    sudo -u amavis sa-learn --restore file.txt
    Or you could setup bayes to store in SQL and specify the username there, and you should be able to import it as any user (eg. root) who can read the spamassassin config file (eg.
    grep bayes_ /etc/spamassassin/
    bayes_store_module                 Mail::SpamAssassin::BayesStore::MySQL
    bayes_sql_dsn                      DBI:mysql:spamassassin:localhost
    bayes_sql_username                 spamassassin
    bayes_sql_password                 supersecret
    bayes_sql_override_username        amavis
    bayes_expiry_max_db_size 5000000
    bayes_auto_expire 0
    bayes_auto_learn 0
    bayes_learn_during_report 0
    bayes_learn_to_journal 1
    bayes_token_sources all
    (You would need to create the spamassassin database and mysql user for that .. refer to /usr/share/doc/spamassassin/sql/README.bayes.gz).

    If by 'transfer it' you mean your previous spamassassin config, check the files under /etc/spamassassin/ and manually copy settings over, and pay attention to the spamassassin version numbers on the old and new server (many settings will carry forward from older versions to new, but some become obsolete, and there are new plugins to enable/configure, etc.). You might refer to general info on configuring spamassassin for that.

    Not in a standard ISPConfig install, only the 'amavis' user is used.
  3. mikolaj_koziej

    mikolaj_koziej New Member

    Jesse Norell, thank you very much for help :)

Share This Page