Maildir to Zimbra This is a modification of the Maildir import script on the Wiki. It copies the messages to the correct folder on Zimbra, it also will copy folder names with spaces in them, and I've joined the cur/new folder stuff into one loop, rather then two. I've also exempted creation of certain mailboxes that exist within zimbra by default to avoid zmmailbox error delay's.
I'm not a proficient bash coder, so if there is major issues with it please let me know. I've migrated about 300GB with it, without issue.
One thing that it doesn't do is set the flags, I haven't quite figured out how to do that with zmmailbox/zimbra yet. I know I can do it with imapsync, but I'd rather do it from the same script.
#!/bin/bash
#
# Maildir to Zimbra import
# Drop in your user root and run as superuser.
#
domain="domain.com" # change to your domain!
for user in `ls -d1 */|sed s/\\\///`
do
echo
echo "User $user"
echo
#
#
find $user -maxdepth 10 -type d -name cur | while read line;
do
folder=`echo ${line}|cut -f3 -d"/"|sed s/\\\.//`
line2=`echo ${line/%cur/new}`
echo "FOLDER $folder"
if [ "$folder" = "cur" ]
then
/opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage Inbox $PWD/$user/.maildir/cur
/opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage Inbox $PWD/$user/.maildir/new
else
if [ "$folder" != "Sent" ] && [ "$folder" != "Drafts" ] && [ "$folder" != "Junk" ] && [ "$folder" != "Trash" ]
then
/opt/zimbra/bin/zmmailbox -z -m $user@$domain createFolder "/$folder"
fi
/opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage "/$folder" "${PWD}/${line}"
/opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage "/$folder" "${PWD}/${line2}"
fi
done
done
Last edited by drwho18; 11-30-2008 at 05:35 AM..
|