Patrick Westenberg
2012-May-18 21:44 UTC
[Dovecot] Best way to change index location on mdbox
Hi, right now my index directory is part of the users home directory: mail_home = /var/mail/%d/%n mail_location = mdbox:~/mdbox I want the indexes to be stored in a different location: mail_home = /var/mail/%d/%n mail_location = mdbox:~/mdbox:INDEX=/var/indexes/%d/%n If I just switch this setting and reload the configuration, no e-mails are shown to the user. After restoring the whole maildir I deleted all dovecot.index.*-files from that user and starting dovecot with the new index directory setting, I got the following error after connecting. I expected the index files to be regenerated but I got an error: May 18 23:11:12 imap(test at example.com): Panic: file mail-storage.c: line 787 (mailbox_check_mismatching_separators): assertion fail ed: (strncmp(vname, ns->prefix, ns->prefix_len-1) == 0) May 18 23:11:12 imap(test at example.com): Error: Raw backtrace: /usr/local/lib/dovecot/libdovecot.so.0(+0x4475a) [0x7f993f60875a] -> /usr/local/lib/dovecot/libdovecot.so.0(+0x447a6) [0x7f993f6087a6] -> /usr/local/lib/dovecot/libdovecot.so.0(i_error+0) [0x7f993f5df5bf] - > /usr/local/lib/dovecot/libdovecot-storage.so.0(mailbox_open_stream+0) [0x7f993f8ccca0] -> /usr/local/lib/dovecot/libdovecot-storage.so. 0(mailbox_open+0xf) [0x7f993f8cccbf] -> /usr/local/lib/dovecot/libdovecot-storage.so.0(mdbox_storage_rebuild_in_context+0xb2b) [0x7f993f8 8eeab] -> /usr/local/lib/dovecot/libdovecot-storage.so.0(mdbox_sync_begin+0x7ec) [0x7f993f88ce7c] -> /usr/local/lib/dovecot/libdovecot-st orage.so.0(mdbox_sync+0x46) [0x7f993f88cee6] -> /usr/local/lib/dovecot/libdovecot-storage.so.0(mdbox_storage_sync_init+0x87) [0x7f993f88c fc7] -> /usr/local/lib/dovecot/libdovecot-storage.so.0(mailbox_sync_init+0x31) [0x7f993f8cb851] -> /usr/local/lib/dovecot/libdovecot-stor age.so.0(mailbox_sync+0x27) [0x7f993f8cc387] -> /usr/local/lib/dovecot/libdovecot-storage.so.0(index_storage_get_status+0x28f) [0x7f993f8 ef41f] -> dovecot/imap(imap_status_get+0x7a) [0x41756a] -> dovecot/imap(cmd_status+0x14f) [0x40e85f] -> dovecot/imap(command_exec+0x3d) [ 0x41158d] -> dovecot/imap() [0x41050e] -> dovecot/imap() [0x4105ed] -> dovecot/imap(client_handle_input+0x135) [0x410815] -> dovecot/imap (client_input+0x5f) [0x41113f] -> /usr/local/lib/dovecot/libdovecot.so.0(io_loop_call_io+0x36) [0x7f993f6148f6] -> /usr/local/lib/dovecot /libdovecot.so.0(io_loop_handler_run+0x9f) [0x7f993f61592f] -> /usr/local/lib/dovecot/libdovecot.so.0(io_loop_run+0x28) [0x7f993f614898] -> /usr/local/lib/dovecot/libdovecot.so.0(master_service_run+0x13) [0x7f993f601023] -> dovecot/imap(main+0x2a4) [0x419364] -> /lib/libc.s o.6(__libc_start_main+0xfd) [0x7f993f280c8d] -> dovecot/imap() [0x408e89] How can I change the index directory without losing mails? Patrick
On Fri, 2012-05-18 at 23:44 +0200, Patrick Westenberg wrote:> right now my index directory is part of the users home directory: > mail_home = /var/mail/%d/%n > mail_location = mdbox:~/mdbox > > I want the indexes to be stored in a different location: > mail_home = /var/mail/%d/%n > mail_location = mdbox:~/mdbox:INDEX=/var/indexes/%d/%n > > If I just switch this setting and reload the configuration, no e-mails > are shown to the user.You must not lose indexes with mdbox or you'll lose message flags and mails may also end up going to wrong mailboxes.> After restoring the whole maildir I deleted all dovecot.index.*-files > from that user and starting dovecot with the new index directory > setting, I got the following error after connecting. > I expected the index files to be regenerated but I got an error: > > May 18 23:11:12 imap(test at example.com): Panic: file mail-storage.c: line > 787 (mailbox_check_mismatching_separators): assertion fail > ed: (strncmp(vname, ns->prefix, ns->prefix_len-1) == 0)This is a little bit strange bug that is also happening to another guy. I haven't been able to reproduce it.> How can I change the index directory without losing mails?The easiest and the most reliable solution would be to just move the index files to their new location while Dovecot is stopped.