Migrate a Full cPanel Account via SSH
In this article
This guide walks you through migrating a complete cPanel account from one server to another using SSH. You'll transfer the account archive, restore it on the destination server, and update DNS — all without touching the cPanel web interface. This method is ideal for server administrators who need a reliable, scriptable migration path.
What You'll Need
- SSH access (root or a user with
sudoprivileges) on both source and destination servers. - cPanel/WHM installed on both servers (versions should be reasonably close).
- Enough disk space on the destination server to hold the account archive (typically the size of the account's home directory plus a margin).
- The account's username and domain name.
- Ability to update DNS records for the domain (or control over the nameserver).
Step-by-Step
- Log into the source server via SSH. Use your terminal:
ssh root@source-server-ip(or your user with sudo). - Create a full cPanel backup for the account. Run the following command, replacing
usernamewith the actual cPanel username:/scripts/pkgacct username
This creates a compressed archive (usually in/home/usernameor/home) named something likecpmove-username.tar.gz. - Verify the backup file exists. Check with
ls -lh /home/cpmove-username.tar.gz(adjust path if needed). Note the exact path and filename. - Transfer the backup to the destination server. Use
scp(secure copy) from the source server:scp /home/cpmove-username.tar.gz root@destination-server-ip:/home/
If you prefer rsync (more robust for large files), use:rsync -avz /home/cpmove-username.tar.gz root@destination-server-ip:/home/ - Log into the destination server via SSH.
ssh root@destination-server-ip - Restore the account from the backup. Run:
/scripts/restorepkg username
This extracts the archive and recreates the account, including databases, email accounts, cron jobs, and DNS zone (if managed by cPanel). - Check the restoration log. The restore process outputs a log. Look for any errors, especially regarding database restoration or missing features. You can also check
/var/cpanel/logs/restorepkg.log. - Verify the account is active. Run
whmapi1 listacctsor simply try to log into cPanel for that user. Ensure the website loads on the destination server (temporarily point your local hosts file or use a test URL). - Update DNS records. Change the domain's A record (and any other relevant records) to point to the destination server's IP. This is done at your DNS provider or nameserver. Propagation can take a few hours to 48 hours.
- Test everything after propagation. Once DNS has propagated, verify email, website, databases, and any SSL certificates. If the domain had SSL, you may need to re-issue or reinstall the certificate on the new server.
Common Mistakes
- Forgetting to update DNS — the most common oversight. The site will appear down if DNS still points to the old server.
- Not checking disk space on the destination server before restoring. A full disk will cause partial restoration or failure.
- Ignoring restore errors — always read the log. A failed database restore can break the site silently.
- Restoring over an existing account — if the account already exists on the destination,
restorepkgmay overwrite or conflict. Remove the old account first or use a different username. - Not considering PHP/MySQL versions — if the destination server runs different versions, scripts might break. Test thoroughly.
Tips
- Before migrating, clean up the source account: delete old backups, empty trash, and remove unused files to reduce transfer size.
- Use
rsyncinstead ofscpfor large accounts — it resumes interrupted transfers and verifies data integrity. - If the account uses custom DNS records (like DKIM, SPF), back them up manually. The restore usually includes them, but it's safer to have a copy.
- Perform the migration during a low-traffic window to minimize disruption.
- Consider using cPanel's built-in “Transfer Tool” in WHM as an alternative — it automates many steps, but SSH gives you more control.
Troubleshooting
- Restore fails with “No such file or directory” — ensure the backup file is in the expected location and the username matches the archive name. Use
lsto confirm. - Website shows old content after DNS update — clear your local DNS cache or use a different device. Also, check that the web server on the destination is properly serving the account.
- Email not working — verify MX records point to the correct server, and that mail services (Exim, Dovecot) are running on the destination. Check
service exim statusandservice dovecot status. - Database connection errors — confirm the database user and password were restored. You may need to reset the password via WHM or cPanel if it didn't transfer.
- SSL certificate errors — reissue the certificate via WHM (AutoSSL or manual). The private key might not transfer perfectly.
- Transfer interrupted — re-run the rsync or scp command; rsync will resume from where it left off.
Frequently Asked Questions
Will this transfer my SSL certificates?
cPanel backups include SSL certificates and private keys, but they may not be automatically installed. You may need to re-issue them via WHM after restoration.
How long does the migration take?
It depends on the account size and server speed. A small account might take minutes; a large one with many files could take hours.
Can I migrate multiple accounts at once?
Yes, you can run /scripts/pkgacct for each account, or use WHM's “Transfer Tool” for bulk migration. For SSH, you'd script a loop.
What if the destination server has a different cPanel version?
Generally fine, but older versions may not support newer backup features. It's best to upgrade the destination to the latest stable version before restoring.
Do I need to disable the source account during migration?
Not necessarily, but to avoid data inconsistency, you might want to suspend the account or put it in maintenance mode temporarily.
Will my cron jobs be restored?
Yes, cron jobs are included in the backup and restored automatically.