How problematic to migrate email from a cPanel server to ISPC?

Discussion in 'General' started by schwim, Jun 22, 2018.

  1. schwim

    schwim Member

    Hi there everyone!

    I did a bunch of searching on this. I found some old scripts on Github and other repos and I've found sites where people bid on doing this type of job for you but I'm at the very early stages of contemplating moving one of my cPanel servers to one I'm running ISPC on.

    I've explored the mail folder in the user's root on cPanel and the structure makes some sense to me. Would this be something I could move to the same domain and email address on the ISPC server? If so, could someone tell me roughly what it would entail?

    Thanks for your time!
  2. schwim

    schwim Member

    Bumping for some love. Not looking for someone to do the work for me but would like to know if it's possible and if so, what the general process would be.

    Thanks for your time!
  3. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    What is the folder structure in cpanel? If it's maldir format you can probably just rsync the directories over to the correct path on ISPConfig, then fix up ownership/permissions. It might be easier to create the mail accounts on the new server first.

    If you have a lot of accounts/domains involved, or just want another option, I believe the migration tool can handle cpanel source servers and might make everything easier.
  4. schwim

    schwim Member

    Here's how the folder/file structure works in cPanel:

    mail root:


    imap folder:


    mail files inside folder:


    If the migration tool page is to be believed, cPanel is not one of the options:

  5. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Well then, that's just my bad memory. :) Rsync is simple enough to use scripted; I adapted a script I've used for copying mail from DTC servers. Setup passwordless root ssh from your ispconfig mail server to your cpanel box. Create the domain and all mailboxes on the ispconfig host first, then login to the ispconfig mail server and try the attached script. It is untested, but probably works; maybe try on a small test domain first. If you have huge maildirs, you can run it once before changing dns to make a cutover, then re-run it with --delete to sync up mail again (it will delete mail on the ispconfig server which no longer exists on the cpanel server), then do one last --delete run right before you cut over (and if you think any mail would have been delivered to the old server while dns was changing, you can re-run without --delete after the cutover).

    # Script to copy mailboxes from CPanel server to local ispconfig server
    function usage() {
            echo "Usage: `basename ${0}` [--delete] domain"
            exit 1
    if [ "${1}" == "--delete" ]
            RSYNC_FLAGS="${RSYNC_FLAGS} --delete"
    test -z "${DOM}" && usage
    if [ ! -d /var/vmail/${DOM}/ ]
        echo "It looks like the domain ${DOM} is not setup on this mail server yet." 1>&2
        exit 1
    cd /var/vmail/${DOM}/
    for U in *
        rsync -avP -e ssh --chown=vmail:vmail ${RSYNC_FLAGS} \
            ${SRV}:/mail/${DOM}/${U}/ \
        sleep 1
    I'm guessing cpanel will be using dovecot imap server, but if they're using courier, you might need to run the migration script after each rsync (just add it to the above script right above the "sleep 1":
  6. adammazin

    adammazin New Member

    nice job, well done
    works like charm

Share This Page