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 straightforward if you follow along carefully. Let’s get started!
- 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.
- 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. - 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.
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.
Keep reading
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 Migrate cPanel Account: Single Account and Bulk Transfer via Terminal
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...
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...