Hi,
I just migrated from dovecot 1.0.rc29 to 1.1.7, from Sparc platform to
Intel, it went very well.
In the process I merged folders and excluded folders from being copied.
User rights on folders were kept/set.
I thought I'd share my migration script with you folks. If there's an
interest to put it on the wiki I can do that, but I'm not sure in what
page.
Use it as a starter if you need to do this yourselves.
Prerequisites:
* User names are local unix accounts
* Old server's /home must be mounted with nfs
* Structure and user names must match between the two systems
* Source dovecot must be at least version 1.0.x
* Destination dovecot must be 1.1.x
* Only dovecot data folders and files are copied, neither dovecot
indices nor Sieve scripts etc.
Here it goes, have fun!
/Peter
#!/bin/sh
#
# Migrates dovecot Maildir folders and settings from older dovecot on
# old server to new dovecot on new server.
# Prerequisites:
# * User names are local unix accounts
# * Old server's /home must be mounted with nfs
# * Structure and user names must match between the two systems
# * Source dovecot must be at least version 1.0.x
# * Destination dovecot must be 1.1.x
# * Only dovecot data folders and files are copied, neither dovecot indices nor
Sieve scripts etc.
#
# Originally created by Peter Lindgren <peter at norrskenkonsult.com>
# Use this script at your own risk. No warranties whatsoever, of any kind!
# Basic settings: The first one you must definitely change, it's where you
have mounted the old server's home:
SOURCEBASE=/mnt/casiopea-home
DESTBASE=/home
# Just an abbreviation:
MD=Maildir
# Change field separator, for find's sake as there might be folders with
spaces:
# (doesn't play well together with the for loop otherwise)
OLDIFS=${IFS}
IFS='
'
# User loop:
# Depending on your source system's setup,
# you probably have non-interactive users with home directories (one of them
# is probably named _dovecot) that shall not be copied. Edit the username
# exclusion list according to your needs.
#
for username in `ls $SOURCEBASE`; do
{
# This is your username exclude list:
case $username in (maildir|_dovecot) continue;; esac
# Here starts the real work:
SOURCEDIR=$SOURCEBASE/$username/$MD
DESTDIR=$DESTBASE/$username/$MD
echo "================================"
echo "Copying user "$username"..."
echo "From "$SOURCEDIR" to "$DESTDIR":"
# IMAP Folder loop:
# Will create the Maildir folder too, the first echo $SOURCEDIR"/."
does that. This way all the copying is in one place only.
for sourceimap in `{ echo $SOURCEDIR"/." ; find $SOURCEDIR -type d
-name \.\* -maxdepth 1 -print ; } | sort -f`; do
{
# Folder exlusion and special actions:
# .Draft is replaced by .Drafts, so content of .Draft must be copied to
.Drafts.
# (Probably there were a client in use for a while that used .Draft instead
of .Drafts.)
# Junk mail folders with various names from clients using different
languages shall not be copied.
# .Trash shall not be copied either.
# Folder .INBOX is a leftover from earlier versions of dovecot, and shall
not be copied either.
# Add your own exceptions to the list. Be sure to quote spaces and dots.
basename=`basename $sourceimap`
action=copy
case $basename in (\.Junk|\.Junk\ E-mail|\.Correo\ electr\&APM-nico\
no\ deseado|\.Skr\&AOQ-ppost|\.Trash|\.INBOX) action=skip;; esac
echo -n "$basename" "$action"
if [ $action"X" == copy"X" ]; then
{
echo -n ":"
destname=$basename
# Merge contents of .Draft and .Drafts to .Drafts:
if [ $basename"X" == .Draft"X" ]; then
destname=${destname}"s"; fi
destimap=${DESTDIR}/${destname}
# If this is the Maildir folder (.), a clean desination name is needed
for mkdir:
if [ $basename"X" == ."X" ]; then
destimap=${DESTDIR}; fi
mkdir -m 700 "${destimap}"
echo -n "."
chown ${username} "${destimap}"
echo -n "."
chmod go-rx "${destimap}"
echo -n "."
cp -p "${sourceimap}/dovecot-uidlist" "${destimap}"
echo -n "."
cp -p "${sourceimap}/dovecot-keywords" "${destimap}"
echo -n "."
cp -pR "${sourceimap}/cur" "${destimap}"
echo -n "."
cp -pR "${sourceimap}/new" "${destimap}"
echo -n "."
cp -pR "${sourceimap}/tmp" "${destimap}"
echo " done."
}
else
{
echo ""
}
fi
}; done
# Copy root folder files last in user loop, since the Maildir is created in
the imap loop above:
cp -p $SOURCEDIR/subscriptions $DESTDIR
echo "User "${username}" done."
}; done
IFS=${OLDIFS}
--
Peter Lindgren
http://www.norrskenkonsult.com