Thanks for the suggestions guys.
I went with installing imapsync and used that.
Took a little while as I had to install a bunch of perl dependencies but once I’d done that it was pretty much smooth sailing.
Transferred about 10,000 emails over pretty quickly with no problems.
If anyone would like to know my process, from my terminal I did the following:
then run the following which checks you have all the required dependencies
perl -c imapsync
If you get some sort of @INC error message then you are missing some things.
There’s some info here if you’d like to know how to check which dependencies are missing and how to install them.
Then once they;re sorted you can go ahead and install imapsync
git clone git://github.com/imapsync/imapsync.git
cd imapsync
mkdir dist
sudo make install
Once all that was done I was able to run something similar to the syntax used in pryley’s example above and the script did the rest.
Thanks for the notes, pryley and thingsofrandomness, I used them to transfer some large mailboxes from my old server to my MIAB before I switched DNS and things like that.
Below is the full list of stuff I typed to get it all working. I installed and ran imapsync on my MIAB host itself, so used ‘localhost’ as the destination hostname in the command. I set up the email account using the MIAB admin web interface.
# Put IMAP password here.
$ vi my_password.txt
# Loop until all mail has been sync-ed
$ while ! imapsync \
--host1 mydomain.com \
--user1 me@mydomain.com \
--passfile1 my_password.txt \
--host2 localhost \
--user2 me@mydomain.com \
--passfile2 my_password.txt \
--port2 993 \
--ssl2 \
--useuid \
--nofoldersizes
do
echo "imapsync for me@mydomain.com bailed for some reason - restarting"
done
I ended up with some duplicate emails from running imap_sync as above. --useid caches message IDs in a temp file, and will skip them the next run. However, a box reboot seemed to remove the ID cache, so I ended up with a few thousand duplicates before I noticed.
I changed the imap_sync invocation to remove --useid, which may be slower, but avoids duplicates even after reboots.
I ended up running a bash one-liner to remove the duplicates. reformail uses the Message-ID header to find dups.
$ sudo su -
$ apt-get install courier-maildrop
$ cd /home/user-data/mail/mailboxes/mydomain.com/myuser/cur
$ > /tmp/mesg_dups ; for mesg in $(find . -type f); do reformail -D 10000000 /tmp/mesg_dups < "$mesg" && rm -v "$mesg"; done
$ apt-get remove courier-maildrop courier-authdaemon courier-authlib courier-authlib-userdb courier-base courier-maildrop expect gamin libgamin0 libtcl8.6
The apt-get removal list is taken from the list of extra dependencies installed along with courier-maildrop.