[Dovecot] Automatic Index Generation
Hello,
I'm looking for an application/script/etc. which will allow me to recreate dovecot indexes by hand from shell. I'm preparing myself for migration to dovecot 1.0.rc15 (debian stable) and would like to create indexes before users start to login into new server to ease the load. My other option is to write a script which will log as each user and create indexes, however this seems a bit of painful way to do it. Anybody can point me in right direction?
-- Maciej Poszywak
On Thu, 2007-12-06 at 13:35 +0100, Maciej Poszywak wrote:
I'm looking for an application/script/etc. which will allow me to recreate dovecot indexes by hand from shell. I'm preparing myself for migration to dovecot 1.0.rc15 (debian stable)
Post-v1.0.0 releases would be better, there have been a lot of fixes since then. backports.org for example has newer releases.
and would like to create indexes before users start to login into new server to ease the load. My other option is to write a script which will log as each user and create indexes, however this seems a bit of painful way to do it. Anybody can point me in right direction?
I guess you're using maildirs? And you're migrating existing users' mailboxes? Do your users use actual IMAP clients or webmail?
I'm not sure if you should worry about creating the indexes. If your users use IMAP clients, just make sure you preserve UIDVALIDITY and UIDs for messages, otherwise most of the clients will download all mails again.
If you use webmail, there's some point in placing fields it accesses to dovecot.index.cache files. The only way to do this is to execute IMAP FETCH commands that accesses those fields.
If you were thinking about just generating dovecot-uidlist and the main dovecot.index file, don't bother. Their creation is practically free.
Timo Sirainen wrote:
I guess you're using maildirs? And you're migrating existing users mailboxes? Do your users use actual IMAP clients or webmail?
POP3 and webmail.
I'm not sure if you should worry about creating the indexes. If your users use IMAP clients, just make sure you preserve UIDVALIDITY and UIDs for messages, otherwise most of the clients will download all mails again.
UIDs are already taken care of and thoroughly tested.
If you were thinking about just generating dovecot-uidlist and the main dovecot.index file, don't bother. Their creation is practically free.
It's not for a mailbox which has 30k+ messages and inbox around 600MB in size. Takes a while to build the index, I have tested this already. First login and index creation takes around 4-6 minutes, then next one just few seconds.
-- Maciej Poszywak
On Sun, 2007-12-09 at 10:35 +0100, Maciej Poszywak wrote:
Timo Sirainen wrote:
I guess you're using maildirs? And you're migrating existing users mailboxes? Do your users use actual IMAP clients or webmail?
POP3 and webmail. ..
If you were thinking about just generating dovecot-uidlist and the main dovecot.index file, don't bother. Their creation is practically free.
It's not for a mailbox which has 30k+ messages and inbox around 600MB in size. Takes a while to build the index, I have tested this already. First login and index creation takes around 4-6 minutes, then next one just few seconds.
I guess you mean logging in with POP3? There the slowdown comes from getting all messages' virtual sizes. So your preindexer could probably do this by running pop3 for all users. If you use only a single UID for users, you could do something like:
for user in cat users
; do
export MAIL=maildir:/home/$user/Maildir
echo "quit" | /usr/local/libexec/dovecot/pop3
done
Timo Sirainen wrote:
I guess you mean logging in with POP3? There the slowdown comes from getting all messages' virtual sizes. So your preindexer could probably do this by running pop3 for all users. If you use only a single UID for users, you could do something like:
for user in
cat users
; do export MAIL=maildir:/home/$user/Maildir echo "quit" | /usr/local/libexec/dovecot/pop3 done
vmu1@test:~$ env | grep MAIL MAIL=maildir:/var/mail/testuser vmu1@test:~$ echo "quit" | /usr/lib/dovecot/pop3 pop3(vmu1): Fatal: pop3_uidl_format setting is missing from config file
I have pop3_uidl_format correctly defined in the config file. I've also tried to strace pop3, to find where it does look for it, but with no success.
On Sun, 2007-12-09 at 16:29 +0100, Maciej Poszywak wrote:
Timo Sirainen wrote:
I guess you mean logging in with POP3? There the slowdown comes from getting all messages' virtual sizes. So your preindexer could probably do this by running pop3 for all users. If you use only a single UID for users, you could do something like:
for user in
cat users
; do export MAIL=maildir:/home/$user/Maildir echo "quit" | /usr/local/libexec/dovecot/pop3 donevmu1@test:~$ env | grep MAIL MAIL=maildir:/var/mail/testuser vmu1@test:~$ echo "quit" | /usr/lib/dovecot/pop3 pop3(vmu1): Fatal: pop3_uidl_format setting is missing from config file
I have pop3_uidl_format correctly defined in the config file. I've also tried to strace pop3, to find where it does look for it, but with no success.
It gets it from environment:
POP3_UIDL_FORMAT=... pop3
In general all settings are passed in environment using uppercased names.
On Sun, 9 Dec 2007, Timo Sirainen wrote:
On Sun, 2007-12-09 at 16:29 +0100, Maciej Poszywak wrote:
Timo Sirainen wrote:
I guess you mean logging in with POP3? There the slowdown comes from getting all messages' virtual sizes. So your preindexer could probably do this by running pop3 for all users. If you use only a single UID for users, you could do something like:
for user in
cat users
; do export MAIL=maildir:/home/$user/Maildir echo "quit" | /usr/local/libexec/dovecot/pop3 donevmu1@test:~$ env | grep MAIL MAIL=maildir:/var/mail/testuser vmu1@test:~$ echo "quit" | /usr/lib/dovecot/pop3 pop3(vmu1): Fatal: pop3_uidl_format setting is missing from config file
I have pop3_uidl_format correctly defined in the config file. I've also tried to strace pop3, to find where it does look for it, but with no success.
It gets it from environment:
POP3_UIDL_FORMAT=... pop3
In general all settings are passed in environment using uppercased names.
In other words, you (Maciej) probably don't want to run 'pop3' directly. I suspect you'd rather do:
/path/to/dovecot --exec-mail pop3
This will set up the environment for the 'pop3' executable the same way dovecot normally does it.
Best, Ben
On Sun, 2007-12-09 at 13:48 -0500, Benjamin R. Haskell wrote:
vmu1@test:~$ echo "quit" | /usr/lib/dovecot/pop3 pop3(vmu1): Fatal: pop3_uidl_format setting is missing from config file
I have pop3_uidl_format correctly defined in the config file. I've also tried to strace pop3, to find where it does look for it, but with no success.
It gets it from environment:
POP3_UIDL_FORMAT=... pop3
In general all settings are passed in environment using uppercased names.
In other words, you (Maciej) probably don't want to run 'pop3' directly. I suspect you'd rather do:
/path/to/dovecot --exec-mail pop3
This will set up the environment for the 'pop3' executable the same way dovecot normally does it.
Yes, I was going to mention that but I wasn't sure how well it'd work when you want to run it for multiple users. At least you can't then override MAIL environment directly, but rather you need to override USER and/or HOME.
On Sun, 9 Dec 2007, Timo Sirainen wrote:
On Sun, 2007-12-09 at 13:48 -0500, Benjamin R. Haskell wrote:
vmu1@test:~$ echo "quit" | /usr/lib/dovecot/pop3 pop3(vmu1): Fatal: pop3_uidl_format setting is missing from config file
I have pop3_uidl_format correctly defined in the config file. I've also tried to strace pop3, to find where it does look for it, but with no success.
It gets it from environment:
POP3_UIDL_FORMAT=... pop3
In general all settings are passed in environment using uppercased names.
In other words, you (Maciej) probably don't want to run 'pop3' directly. I suspect you'd rather do:
/path/to/dovecot --exec-mail pop3
This will set up the environment for the 'pop3' executable the same way dovecot normally does it.
Yes, I was going to mention that but I wasn't sure how well it'd work when you want to run it for multiple users. At least you can't then override MAIL environment directly, but rather you need to override USER and/or HOME.
Maybe it'd be easiest with 'su'? Something along the lines of:
su username -l -c /path/to/dovecot --exec-mail pop3
(Though this doesn't seem to be working for me. I've reïnstalled dovecot too many times. Something's up with permissions.)
Another way that might be relatively easy:
Set up, in dovecot.conf:
protocol pop3 { # in this section mail_executable = /path/to/envscript.sh
And, in /path/to/envscript.sh:
#!/bin/sh env > /path/to/saved-environment exec /path/to/pop3
That'll give you all the environment variables dovecot would normally set up. Then you could filter out the user-specific ones to set up manually, and use e.g. envdir (from DJB's daemontools) to handle the common ones:
$ mkdir common-env $ perl -F= -lanwe 'my $var = shift; open my $f, ">common-env/$var" or die ">$var: $!"; print $f join "=", @F' /path/to/saved-environment
Then:
env USER=blah HOME=blah MAIL=blah envdir /path/to/common-env /usr/libexec/dovecot/pop3
Best, Ben
On 12/9/2007, Maciej Poszywak (jet@surreal.pl) wrote:
I have pop3_uidl_format correctly defined in the config file. I've also tried to strace pop3, to find where it does look for it, but with no success.
dovecot -n output would prove it, and possibly give more of a hint...
--
Best regards,
Charles
El Thursday 06 December 2007 13:35:26 Maciej Poszywak escribió:
My other option is to write a script which will log as each user and create indexes, however this seems a bit of painful way to do it.
That's almost the way I did; using a master user is quite simple, and even if it's no optimal, I did going into production, so time was not an issue.
I used the attached perl script, where
$pop3_password is the password for the master user /home/lgstosej/tmp/passwd is a copy of /etc/passwd
HTH
Joseba Torre. CIDIR Bizkaia.
participants (5)
-
Benjamin R. Haskell
-
Charles Marcus
-
Joseba Torre
-
Maciej Poszywak
-
Timo Sirainen