πŸ”„ Manual Account Transfer With Rsync

This guide explains how to manually migrate a single cPanel account from a source server to a destination server using rsync for secure and efficient file transfers.


πŸ› οΈ Prerequisites

  • Root SSH access to both source and destination servers
  • Optional: Install screen to prevent session timeouts during large transfers
  • Identify the cPanel username (e.g., exampleuser) you want to transfer

1. πŸ” Identify cPanel Username & Home Directory

On the source server, run:

grep '^example.com' /etc/userdomains | cut -d ' ' -f2

Then confirm the user’s home directory:

awk -F ':' '/exampleuser/ {print $6}' /etc/passwd

2. πŸ“¦ Create Account Backup (Excluding Home Directory)

(Optional) Start a screen session:

screen -S transfer-session

Create a working directory:

mkdir -pv /root/site-migration/source-server
cd /root/site-migration/source-server

Run the backup (excluding /home/exampleuser):

/usr/local/cpanel/scripts/pkgacct --skiphomedir exampleuser /root/site-migration/source-server

Verify the backup:

tar -tzf cpmove-exampleuser.tar.gz

3. πŸ›’οΈ Dump Large Databases (Optional)

Prepare the database directory:

mkdir databases
cd databases

List all user databases:

mysql -se 'SHOW DATABASES LIKE "exampleuser\_%"'

Dump each database:

mysqldump exampleuser_db1 > exampleuser_db1.sql
mysqldump exampleuser_db2 > exampleuser_db2.sql

4. πŸ“€ Transfer Backup Files to Destination Server

(Optional) Start a screen session on the destination server:

screen -S transfer-session

Use rsync to transfer:

rsync -avPhz [email protected]:/root/site-migration/source-server /root/site-migration

Verify the files:

ls -lah /root/site-migration/source-server/

5. πŸ”„ Restore Account on Destination Server

Run the restore script:

/usr/local/cpanel/scripts/restorepkg /root/site-migration/source-server/cpmove-exampleuser.tar.gz

Identify the new home directory:

grep 'exampleuser' /etc/passwd | awk -F ':' '{print $6}'

Transfer the home directory:

rsync -avPhz [email protected]:/home/exampleuser/ /home/exampleuser/

Verify:

ls -lah /home/exampleuser/

6. πŸ—„οΈ Import Databases on Destination Server

Navigate to the dump folder:

cd /root/site-migration/source-server/databases/

Import the SQL files:

mysql exampleuser_db1 < exampleuser_db1.sql
mysql exampleuser_db2 < exampleuser_db2.sql

βœ… Final Steps

  • Thoroughly test the website on the destination server
  • Use your local /etc/hosts file to preview the domain before updating DNS
  • Only update DNS after confirming full functionality

πŸ“˜ Tip: For more advanced options, consult the official cPanel Account Restore Guide.

Scroll to Top