0

I am doing a migration from mbox to mdbox on a new disk. From /mnt/mail/$user to /mnt/mail2/$user

Current mail_location = mbox:~/mail:INBOX=/mnt/mail/%u/mail/Inbox

The new mail_location = mdbox:/mnt/mail2/$user/mdbox

My main userdb is passwd, and i have an override for all the users with another userdb:

userdb {
  driver = passwd
  result_success = continue-ok
}

userdb {
  driver = passwd-file
  args = username_format=%u /etc/dovecot/passwd.override
  skip = notfound
}

First step, overriding mail_location for that user:

$user:::::::userdb_mail_location=/mnt/mail2/%u/mdbox

Starting migration:

doveadm sync -f -u $user mbox:/mnt/mail/$user/mail:INBOX=/mnt/mail/$user/mail/Inbox

Sync goes well, all the folders and mails are there in the mdbox location on /mnt/mail2/$user/mdbox.

The home directory of that user is then changed from /mnt/mail/$user to /mnt/mail2/$user, permissions are set.

/etc/passwd shows that home dir of the user is /mnt/mail2/$user.

/etc/dovecot/passwd.override has the new mdbox mail_location for that user.

Unfortunately, when new mail arrives, it still goes to the old mbox.

Postfix uses dovecot-lda as delivery agent:

mailbox_command = /usr/lib/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT"

Is it possible dovecot-lda doesn't understand the override? And why it still delivers to the old $HOME for that user, no matter that it was changed?

tilkov
  • 113
  • 1
  • 6

2 Answers2

1

The problem was that dovecot-lda does not do userdb lookups, and my overridden mail_location was not in effect. Mentioned in the docs, and the answer is to add -d "$USER" to the parameters.

In postfix the configuration for mailbox_command should be:

mailbox_command = /usr/lib/dovecot/dovecot-lda -d "$USER" -f "$SENDER" -a "$RECIPIENT"

tilkov
  • 113
  • 1
  • 6
0

Have you looked into https://wiki2.dovecot.org/Migration/MailFormat? This is usually very easy to do with dsync using the instructions there.

cmouse
  • 468
  • 3
  • 10