Migrating cPanel Email Accounts Without Website Data: A Niche Yet Essential Guide

Image depicting the migration of cPanel email accounts, focusing on email continuity and server transition.

Part 1: Extract Email Addresses from the Old cPanel Server

  1. SSH into the Old cPanel Server: Log in to your old cPanel server using SSH.
  2. Navigate to the Domain Directory:
    cd /home/[username]/etc/[yourdomain.com]/
    Replace [username] and [yourdomain.com] with your actual cPanel username and domain.
  3. Extract Email Addresses: Create a list of email addresses:

    for email in *; do
    if [ -d "$email" ]; then
    echo "${email}@yourdomain.com"
    fi
    done > email_addresses.csv

Part 2: Create Email Accounts on the New cPanel Server with Unlimited Quotas

  1. SSH into the New cPanel Server: Connect to your new cPanel server via SSH.
  2. Use cPanel Scripts to Create Email Accounts with Unlimited Quotas: Use a script to read the email addresses from the CSV file and create email accounts with random passwords:

    #!/bin/bash
    while IFS= read -r email; do
    random_password=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c12)
    /scripts/addpop --email="$email" --password="$random_password" --quota=0
    done < /path/to/email_addresses.csv

    Ensure you have the necessary administrative privileges to run cPanel scripts.

Part 3: Transfer Email Data and Shadow File

I have gone over this section to no end and the only way I have been able to get this to work correctly is to open the /home/[username]/etc/[yourdomain.com]/shadow file on the source server and also on the destination server and as much as I do not advise this to anyone who has not made backups nor made cpmover backups has to copy and paste the contents over the one in that file.

This is the only way I have been able to get this to work correctly since the permissions are a nightmare in anyway that doesn’t require root on both the source server and destination server.

Important Notes

  • Testing: Always test these processes in a controlled environment before applying them to a live server.
  • Security and Compliance: Handle sensitive information like email data and passwords with utmost care.
  • Backup: Create backups of all relevant data before performing any server migration tasks.
  • Permissions and Ownership: Verify and correct file permissions and ownerships as necessary.
  • User Communication: Inform users about the migration process, especially about the temporary passwords and the need to reset them post-migration.

This approach simplifies the migration process by focusing on transferring email addresses and data, setting temporary passwords, and ensuring the encrypted passwords are retained by transferring the shadow file.

Picture of admin

admin

Leave a Reply

Sign up for our Newsletter

Get the latest information on what is going on in the I.T. World.