On 29.01.2009 18:29 Uhr, Mike Hobbs wrote:
Hello,
Hi Mike,
I'm upgrading my mail server from UW to Dovecot and I'd like to convert
from mbox to maildir. I've successfully convert myself and a few other
users with the mb2md script. All is well.
My question is, I have somewhere around 500 users and about 122gb of
mail folders to convert (this does not include the inbox at /var/mail).
mb2md needs to be run as each user to convert. Are there any programs or
scripts out there that will allow me to convert everyone at the same time?
I have created such a script which does a few checks before as well.
We didn't do a 'real' batch conversion, because nothing was in a defined
state at the time of the conversion. We did do it in batches of 10 users
per hour and everyone got an email before, telling them in which
timeframe the migration of their account will take place.
A big help for the migration was perdition (imap proxy) so no
reconfiguration of the client was needed.
I know there is a Dovecot plugin to convert mail, but we didn't want to
use this option.
I'm sure someone on this list was in the same situation as me, how did
you handle a massive conversion?
The attached script does a lot of other things as well, maybe just
reading it will give you an idea of what to expect.
Any help or suggestions is much appreciated!
cheers,
dirk
#!/bin/bash
# m2f - mail to fiction Dirk Essl
PROGNAME=`basename $0`
VERSION=0.5
MUSER=$1
# don't convert the root mailbox and exit if $1 is empty
if [ $1 = root ]; then
echo "you try to convert root (stupid)"
exit 1
fi
# MFROM : Server from which will be migrated from
MFROM=mercury
# MFROMDIR : Directory holding the actual INBOX file (with trailing slash)
MFROMDIR=/net/mercury/var/mail/
# MFROMH : Directory holding the actual mbox format mailboxes
MFROMH=/home/$MUSER/MailImap
# MTO : Server beeing migrated to
MTO=fiction
# MTODIR : Directory holding the new maildirectory (with trailing slash)
MTODIR=/var/maildir/
# POPMAPS : Server holding the NIS map for the perdition Imap Proxy
#POPMAPS=poisson
POPMAPS=tweezers
# POPMAP : filename of the NIS map.
POPMAP=/etc/yp/mailserver
# Don't change anything below here
# create lockfile while compiling the nis map and locking the users mailbox
if [ -f /root/m2f.lock ]; then
echo -e "\033[1;33m##"
echo -e "\033[7;5;1;33m# # # # # # # E R R O R # # # # # # # #
#\\033[0m"
echo -e "\033[1;33man instance of m2f is running"
echo -e "\033[1;33mplease wait until the NIS map is compiled"
echo -e "\033[1;33mif you yhink this is an error, remove the file
m2f.lock"
echo -e "\033[1;33m##"
exit 1
fi
id $MUSER
errlv=$?
if [ $errlv != "0" ]; then
echo -e "\033[7;5;1;33muser $MUSER is not in ESO domain\\033[0m"
exit 1
fi
# check if user is currently hosted in kila or sc6
KILA=`ssh r...@mercury grep $MUSER /etc/mail/mailusers.kila`
if [ "X$KILA" != "X" ]; then
echo "$MUSER is active in kila!"
exit 1
fi
SC6=`ssh r...@mercury grep $MUSER /etc/mail/mailusers.sc6`
if [ "X$KILA" != "X" ]; then
echo "$MUSER is active in sc6!"
exit 1
fi
# check if user has sbd files by grep .mailboxlist
NO_SBD=`su - $MUSER -c 'cat ~/.mailboxlist' | egrep '\.sbd$|\.sbd/'| wc -l`
echo -e $NO_SBD "sbd-files inside .mailboxlist"
if [ $NO_SBD != "0" ]; then
echo -e "\033[1;33m##"
echo -e "\033[7;5;1;33m# # # # # # # E R R O R # # # # # # # #
#\\033[0m"
echo -e "\033[1;33mUser's .mailboxlist mentiones *.sbd-files"
echo -e "\033[1;33mplease postpone converting this user"
echo -e "\033[1;33m##"
exit 1
fi
# check if user has sbd files by find
NO_SBD=`su - $MUSER -c 'find ~/MailImap/ -name "*.sbd"' | egrep 'sbd$'| wc -l`
echo -e $NO_SBD "sbd-files inside MailImap"
if [ $NO_SBD != "0" ]; then
echo -e "\033[1;33m##"
echo -e "\033[7;5;1;33m# # # # # # # E R R O R # # # # # # # #
#\\033[0m"
echo -e "\033[1;33mUser has one or more *.sbd-files inside
MailImap-Folder"
echo -e "\033[1;33mplease postpone converting this user"
echo -e "\033[1;33m##"
exit 1
fi
# check if use