How to Migrate cPanel Account: Single Account and Bulk Transfer via Terminal
In this guide
This tutorial will help you migrate cPanel accounts from one server to another using the terminal. Whether you’re moving one account, all accounts, or just a few selected ones, this guide has you covered. Follow each step carefully, and take your time — there’s no rush!
???? Migrating a Single cPanel Account
- 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.
- Create a Full Backup of the cPanel Account:
Navigate to the home directory first:
cd /home
Now, generate the backup:
/scripts/pkgacct cpanel_username
Hint: Replace cpanel_username with the username of the account you want to move.
Note: This process may take a few minutes depending on the account size. Just wait for it to finish before proceeding.
- Transfer the Backup to the New Server:
Run this command to transfer the backup file:
rsync -av --progress /home/cpmove-cpanel_username.tar.gz root@new_server_ip:/home
Hint: Replace cpanel_username and new_server_ip with the account username and your new server’s IP address.
Note: This step may take several minutes, depending on the file size and connection speed.
- Restore the Backup on the Destination (New) Server:
Now SSH into the new server:
ssh your_username@new_server_ip
Then restore the account backup:
/scripts/restorepkg cpmove-cpanel_username.tar.gz
Note: After this, log in to WHM or cPanel to verify that everything is working correctly.
???? Migrating All cPanel Accounts
- Create Backups for All Accounts:
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.
- 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.
- 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" doneNote: 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.
⚠️ Warning: If there are any .tar.gz files already in the /home directory, consider removing them first. Keeping old backup files might cause confusion or lead
to restoring the wrong account.
???? Migrating Selected (Multiple) cPanel Accounts
- Create Backups for Specific Accounts:
First, move to the correct directory:
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.
Use this script to back up specific accounts:
#!/bin/bash # List of cPanel accounts to create backups accounts=("account1" "account2" "account3") for account in "${accounts[@]}"; do /scripts/pkgacct $account doneHint: Replace “account1” “account2” “account3” with the actual usernames of the accounts you want to migrate.
Note: You can add or remove usernames from the list as needed (ex “account1” “account2” “account3” “account4” “account5” …..). Make sure you wait until the script finishes creating all the backups before moving on.
- Transfer the Backups:
Send the backup files to the new server:
rsync -av --progress /home/*.tar.gz root@new_server_ip:/home
Hint: Replace new_server_ip with your new server’s IP address.
- Restore the Selected Accounts:
SSH into your new server:
ssh your_username@new_server_ip
Go to the home directory first:
cd /home
Restore each account with this command:
for f in /home/cpmove-*.tar.gz; do a=$(basename "$f" .tar.gz) a=${a#cpmove-} /scripts/restorepkg "$a" doneNote: Accounts that already exist on the new server are not overwritten. Always double-check each site after the restore.
⚠️ Warning: If there are any .tar.gz files already in the /home directory, consider removing them first. Keeping old backup files might cause confusion or lead to restoring the wrong account.
✅ Final Tips
- ???? Always make sure SSH access is enabled on both servers and that your firewall allows the connection.
- ???? If you are dealing with a large number of accounts, consider doing a few at a time to avoid overloading your server.
- ???? Migration time depends on the number and size of accounts. A single account may take 5–15 minutes, while many accounts could take hours.
- ???? After restoring, verify DNS settings, SSL certificates, and site functionality.
Keep reading
How to migrate all cPanel accounts using the terminal?
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...
How to migrate a single cPanel account to a new server?
Moving a website to a new server can feel intimidating, but don’t worry — we’ve got you covered. In this guide, you’ll learn how to move a single cPanel account to a new...
How to Safely Change SSH Port in AlmaLinux (e.g., to 2022)
Changing the default SSH port (22) helps protect your server from automated attacks. In this guide, we’ll show you how to change the SSH port safely and open the new...