Migrating from courier-imap without passwords using Imapsync
Migrate e-mail accounts from courier-imap, postfixadmin to zimbra without having user passwords
First, we needed to pull the account names and passwords from postfixadmin over to the new Zimbra system. This article demonstrates a php script that did the job well, querying the encrypted passwords from the MySQL backup into a file. You can also modify it to retrieve aliases and subscribers from MySQL.
Using the exported.sh file, which runs zmprov, it created the users on Zimbra and was able to set their passwords. You may want to grep out all the lines with 'zmprov ma username' into another file, called reset_passwords.sh, to use for reseting account passwords later. (add #!/bin/bash on the top line to make it a script, 'chmod +x reset_passwords.sh' to make it executable.) At this point, we want to change the account passwords to be all the same for the time it takes to do the imapsync migration - add the password to the 'zimpassfile2' file as specified in the imapsync command.
Migrating e-mail using imapsync was complicated when trying to use the --auth-user postfixadmin 'super-user' option, so we decided instead to create a new e-mail account via postfixadmin, called migration1, set a password, and then manually change the symlink for the mail folder in this way:
ln -s /firstname.lastname@example.org /email@example.com
Then running imapsync worked:
/usr/bin/imapsync --buffersize 8192000 --nosyncacls --subscribe --syncinternaldates --host1 postfixserver.domain.com --user1 migration1 \ --passfile1 zimpassfile1 --host2 zimbraserver.domain.com --user2 firstname.lastname@example.org --passfile2 zimpassfile2 --noauthmd5
(I'm sure there are better ways to script all of this. Anyone who wants to add this, it will be welcomed.)
Then delete the symlink and relink it for the next user, so you can run imapsync again:
rm /email@example.com; ln -s /firstname.lastname@example.org /email@example.com
As recommended, we ran two imapsync processes on different servers concurrently to reduce the time for migration. We configured accounts migration1 and migration2 on the old mail server so we could point to two different mail folders at one time under /usr/local/virtual.
After all the accounts have synced, use the reset_passwords.sh script that contains the 'zmprov ma' commands to reset all user passwords to the same ones which they had on the old mail server.