All posts

How to migrate all cPanel accounts using the terminal?

May 16, 2025 2 min read Cyberison Team Updated Dec 4, 2026

If you’re switching servers entirely and want to bring over every single cPanel account, this guide is for you. It’s a bit more time-consuming, but still very straightforward if you follow along carefully. Let’s get started!

  1. Connect to the Source (Old) Server:

    Use SSH from your computer or terminal to access your old server:

    ssh your_username@old_server_ip

    Hint: Replace your_username with your actual SSH user, and old_server_ip with the IP address of your current server.

  2. Go to the home directory first:

    cd /home

    ⚠️ Warning: If there are any .tar.gz files already in the /home directory, consider removing them first to avoid uploading or restoring outdated backups by mistake.

    Then run this command to create backups for all existing cPanel accounts:

    ls /var/cpanel/users | while read a; do
    /scripts/pkgacct $a
    done

    Note: This may take quite a while depending on how many accounts you have and their sizes. Be patient and let it complete before continuing.

  3. Transfer the Backups to the New Server:

    Use this command to send all the backup files to the new server:

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

    Hint: Replace new_server_ip with the IP address of your destination server.

    ⚠️ Warning: If there are any .tar.gz files already in the /home directory in new destination server, consider removing them first. Keeping old backup files might cause confusion or lead
    to restoring the wrong account.

  4. Restore All Accounts on the New Server:

    SSH into your new server:

    ssh your_username@new_server_ip

    Go to the home directory first:

    cd /home

    Run the following to restore each account:

    for f in /home/cpmove-*.tar.gz; do
      a=$(basename "$f" .tar.gz)
      a=${a#cpmove-}
      /scripts/restorepkg "$a"
    done

    Note: If an account with the same username already exists on the new server, restorepkg stops for that account. Remove the old account in WHM first if you really want to replace it. Afterward, check each account in WHM to confirm the migration was successful.

Share this guide