How to Migrate cPanel Account: Single Account and Bulk Transfer via Terminal

cPanel Migration Tutorial

Migrating cPanel accounts between servers is a common task for administrators aiming to optimize server resources or improve performance. This guide will walk you through the process of migrating a single cPanel account, all cPanel accounts, or multiple cPanel accounts to a new server using the terminal.

Migrating a Single cPanel Account

  1. Connect to the Source Server:

    Use SSH to connect to the source server by entering:

    ssh your_username@your_server_ip
  2. Create a Full Backup of the cPanel Account:

    Navigate to the home directory and create a backup of the specific cPanel account:

    cd /home/
    /scripts/pkgacct [cpanel_username]
  3. Transfer the Backup to the Destination Server:

    Transfer the backup file to the new server using `rsync`:

    rsync -av --progress /home/cpmove-[cpanel_username].tar.gz root@103.193.72.49:/home

    Replace 103.193.72.49 with the IP address of your new server.

  4. Restore the Backup on the Destination Server:

    Connect to the new server using SSH:

    ssh your_username@your_server_ip

    Restore the backup with the following command:

    /scripts/restorepkg cpmove-[cpanel_username].tar.gz

    Verify that the migration was successful by checking the new server.

Migrating All cPanel Accounts

  1. Create Backups for All cPanel Accounts on the Source Server:

    Generate backups for all cPanel accounts with the following command:

    ls /var/cpanel/users | while read a; do
    /scripts/pkgacct $a
    done
  2. Transfer All Backups to the Destination Server:

    Use `rsync` to transfer the backup files to the new server:

    rsync -av --progress /home/*.tar.gz root@103.193.72.49:/home

    Replace 103.193.72.49 with the IP address of your new server.

  3. Restore All Backups on the Destination Server:

    Connect to the new server using SSH:

    ssh your_username@your_server_ip

    Restore each backup with the following commands:

    ls /home/ | awk -F'[-.]' '{print $2}' | while read a; do
    /scripts/killacct --user=$a
    /scripts/restorepkg $a
    done

    Verify that all cPanel accounts have been migrated successfully on the new server.

Migrating Multiple cPanel Accounts at a Time

  1. Create Backups for Multiple cPanel Accounts on the Source Server:

    Use the following script to create backups for multiple accounts:

    #!/bin/bash
    
    # List of cPanel accounts to create backups
    accounts=("account1" "account2" "account3")
    
    for account in "${accounts[@]}"; do
        /scripts/pkgacct $account
    done

    Replace "account1" "account2" "account3" with the usernames of the cPanel accounts you wish to back up.

  2. Transfer All Backups to the Destination Server:

    Transfer the backup files using `rsync`:

    rsync -av --progress /home/*.tar.gz root@103.193.72.49:/home

    Replace 103.193.72.49 with the IP address of your new server.

  3. Restore All Backups on the Destination Server:

    Connect to the new server using SSH:

    ssh your_username@your_server_ip

    Restore each backup with the following commands:

    ls /home/ | awk -F'[-.]' '{print $2}' | while read a; do
    /scripts/killacct --user=$a
    /scripts/restorepkg $a
    done

    Ensure that all cPanel accounts have been successfully migrated by verifying on the new server.

Share