Skip to main content

Copy all email accounts from one CPANEL server to a second, possible?

Comments

2 comments

  • cPRex Jurassic Moderator
    Hey there! As you've found, there's not a good way to do this as we don't have a tool available for this type of work. You could always submit a feature request using the link in my signature, and then I can bring that up with the team. To clarify a few points:
    Are all cPanel instances equal i.e. do they all use Maildir++ format for mail storage? If not, how do I find out as a Cpanel admin what is used?

    No, cPanel servers can use either maildir or mdbox. You'll be able to tell the difference in the file structure of the mail directory - if you see things like /cur and /new, that's maildir, if you see INBOX, Archive, Sent, that's mdbox.
    If they all use MailDir++, is it safe to copy files and directories over manually?

    Yes, these are just flat files on the system.
    Does the file structure around the MailDir directories in a cPanel environment explicitly or implicitly contain the account names and passwords? (To be honest, this is going to be the major PITA - recreating all the accounts one by one)

    No - this is stored in /home/username/etc/domain.com in various password, quota, and shadow files. Manually integrating that into an existing cPanel account could certainly be doable, but it would be difficult as you'll have to manually copy each line of the file you need. I wouldn't use any tools that involve having to change the DNS. You could use a third-party tool like Imapsync to move messages, or you could use rsync between the two machines if your cPanel user has SSH access. The short story - there isn't an easy way to do this, and I don't have any step-by-step instructions on my end since it's not something we support.
    0
  • DennisMidjord
    We've done this many times, although not in the scale you're trying to do. It's always been email accounts for a few domains or so. All of our accounts are configured as Maildir. What we usually do is copy both the /home/username/etc/domain.com/ and /home/username/mail/domain.com/ directories to the new server. Once that's done, we set the permissions (`chmod -R username:username /home/username/etc/domain.com/ /home/username/mail/domain.com/`) and then run `/scripts/mailperm username`. That would be everything required for migrating to email accounts to a new server. The above is pretty easy and shouldn't take long. For syncing emails that are received by the old server while DNS changes are propagating, you could write a small shell script that runs every 5-10 minutes and looks for new files. Once a new file is detected, send it to the new server and update the permissions again. If you know the passwords for the accounts, it would be far easier to use a tool such as IMAPSync.
    0

Please sign in to leave a comment.