To migrate a single cPanel account from one server to another using SSH and the terminal, follow these steps:Steps:Login to the Source Server (old server):Use SSH to access the old server (the server where the account currently resides).
ssh root@source_server_ip
2. Create Backups of All Accounts:To back up all cPanel accounts on the server, use the pkgacct script for each account. You can use a for loop to automate this for multiple accounts:
for user in $(ls /var/cpanel/users); do /scripts/pkgacct $user done This will create backups for all cPanel users in the /home directory.
Transfer Backups to the New Server:Once the backups are created, transfer them to the new server using scp or rsync. For example:
scp /home/*.tar.gz root@destination_server_ip:/home/
Or using rsync for faster transfer: rsync -avz /home/*.tar.gz root@destination_server_ip:/home/
Login to the New Server (destination server):SSH into the new server:
ssh root@destination_server_ip
Restore the Backups:To restore the backups, use a for loop to process all .tar.gz backup files. For example:
for backup in /home/*.tar.gz; do /scripts/restorepkg $backup done
Verify the Migration:After the restoration is complete, verify that each cPanel account has been migrated correctly, checking websites, databases, emails, etc.
Additional Notes:Automation: You can automate both single and bulk migrations by creating cron jobs or shell scripts.DNS: Ensure that the DNS records for the domains on the old server are updated to point to the new server’s IP.SSL Certificates: Ensure SSL certificates are transferred if required.Email: Check that email accounts and settings are restored properly, as email configurations sometimes require additional validation.
Using the above methods, you can efficiently migrate both single and multiple cPanel accounts.for backup in /home/*.tar.gz; do /scripts/restorepkg $backup done
