User Tools

Site Tools


docs:tips_n_tricks:dovecot.html

dovecot

Solving "Error: mkdir/chown(.../.imap/INBOX, group=8(mail)) failed"

According to wiki2.dovecot.org the problem is solved by removing the write persmissions to the group on /var/spool/mail/username.

Replication

Troubleshooting

Note: The locally running replicator allways pushes the local changes to the far side (provided it is running without the -R flag)

doveadm replicator status <username pattern>

<username pattern> is something like *@example.com, user@example.com, u* or just *

Run

doveadm replicator status '*' | fgrep ' y'

to find failing mailboxes.

Times shown are the time passed since last fast/full sync.

doveadm replicator dsync-status

Accepts a username pattern as well, but works without it.

doveadm replicator replicate -f <username pattern>

triggers a new full sync. (Needs to be called twice sometimes?)

doveadm force-resync is not related to replication!

Credits:

Deduplication

Sometimes, root cause of replication troubles seem to be duplicated emails. Those might be cleaned up in mailboxes INBOX and Spam for account user@example.com by

deduplicate.sh
while doveadm deduplicate -u user@example.com mailbox INBOX OR mailbox Spam
do
  fgrep -c Message-ID: example.com/user/mail/Spam xid.at/xen/mail/INBOX
  echo "++++ `date` +++++"
done

This will run forever ans should be stopped when numbers do not change any more.

Monitoring

This solution is for nagios-like monitoring systems

This needs a sudo entry to allow nagios running doveadm as dovecot

check_dovecot.sh
  #! /bin/sh
 
  # LANG=C doveadm replicator status|fgrep "'failed'"
  repl_n_wait_fail="`LANG=C sudo -u dovecot doveadm replicator status|sed -ne \"s/^Waiting 'failed' requests *\([0-9]\+\) *$/\1/pg\"`"
  # LANG=C doveadm replicator status|fgrep "'failed'"
  # echo "\"$repl_n_wait_fail\""
 
  case "$repl_n_wait_fail" in
  "0") echo "OK: doveadm replicator status: Waiting 'failed' requests $repl_n_wait_fail"
       exit 0 ;;
  "1") echo "WARN: doveadm replicator status: Waiting 'failed' requests $repl_n_wait_fail"
       exit 1 ;;
  *)   if [ "$repl_n_wait_fail" -gt 1 ]
       then
          echo "CRIT: doveadm replicator status: Waiting 'failed' requests $repl_n_wait_fail"
          exit 2
       fi ;;
  esac
 
 
  echo "UNKNOWN: Strange value in doveadm replicator status for  waiting 'failed' requests: $repl_n_wait_fail"
  exit 3

Remediation

Most cases I observed replication failures could be remedied by forcing deduplication. To my experience, dovecot deduplicate had to be run several times until all duplicate emails were removed.

dovecot deduplicate -u <user> '*'

Repeat until

  grep -c '^Message-ID:' path/to/mailbox
  grep '^Message-ID:' path/to/mailbox | sort -u | wc -l

show the same number.

docs/tips_n_tricks/dovecot.html.txt · Last modified: 01.02.2019 12:36 by peter