cpanel import and exim

Hey folks,

Provided you’ve gotten your cPanel host migrated to Maildir, you could use the following script I crafted up to move your mail data over. Bear in mind, should this script kill your dog, burn down your house, or take a dump in your Cheerios, it’s your problem. I’ve used it to move a couple domains over and have had pretty good luck with it.

I should also mention that you’ll have to run this as root, so use extreme caution.


#!/bin/bash

#Copy cPanel mail data to InterWorx host
#Ghetto-rigged(tm) by mstyne
#Thu Jul 27 18:44:20 EDT 2006

#args : remote-user local-user domain host
#Do yourself a favor and set up an ssh key with no password or an ssh-agent

if [ ! $# == 4 ]; then
        echo "Usage: $0 remote-user local-user domain host"
        exit
fi

for user in $(/bin/ls -1 /home/$2/var/$3/mail); do
rsync -a -v --exclude 'courierimaphieracl/' --exclude 'courierimapkeywords/' --exclude 'courierimapuiddb' --exclude 'courierpop3dsizelist' --exclude '.mailboxlist' $4:/home/$1/mail/$3/$user/ /home/$2/var/$3/mail/$user/Maildir/;
chown -R vpopmail:$2 /home/$2/var/$3/mail/$user/Maildir/;
done