How To Manually Combine Two cPanel Accounts Into One
Step 1. Designate a "Master" cPanel Account
Note: The purpose of this step is to decide which cPanel account to keep. No actions or commands are required as part of this step.
To combine two cPanel accounts into one, you must first choose one account to terminate and one account to keep. For the purpose of this tutorial, we'll refer to the cPanel account you choose to keep as the Master cPanel account and we'll refer to to the cPanel account you choose to terminate as the Secondary cPanel account. For example, let's say you want to combine the following cPanel accounts:
If you designate cPanel Account 1 as the Master cPanel account, then cPanel Account 1 will include domains and data from cPanel Account 2 at the end of this tutorial.
Step 2. Review the Master Account's Package Limits
Review the package limits assigned to the Master cPanel account to ensure they are sufficient to handle the usage from both the Master and Secondary cPanel accounts. For example, if you are merging two cPanel accounts and each account uses 500MB of disk space usage, then the package limits should allow for more than 1000MB of disk space.
Additionally, you should browse to WHM >> Quota Modification and temporarily disable (or set to a very high value) quotas for both the Master and Secondary cPanel accounts until you've completed all steps in this tutorial.
Step 3. Turn Off "Database Prefixing" and "Restrict document roots to public_html"
A. Browse to the SQL tab in WHM >> Tweak Settings and set the following option to Off:
Require a username prefix on names of new databases and database users
This will make it easier to merge databases and database users from multiple accounts.
B. Browse to the Domains tab in WHM >> Tweak Settings and set the following option to Off:
Restrict document roots to public_html
This will make it easier to merge document roots for multiple domains.
Step 4. Verify Recent Backups Exist For Both cPanel Accounts
This is the final step before data is manipulated. It's important to verify recent backups exist for both cPanel accounts prior to proceeding to Step 5. You can use the /usr/local/cpanel/scripts/pkgacct script to create a backup for each account. Additionally, we recommend monitoring the output from the Pkgacct script when generating backups of the cPanel accounts you are merging to ensure no errors occur during the backup process. For more information, read our Pkgacct documentation.
Step 5. Record the Secondary Account's Main Domain, Subdomains, Addon Domains, Aliases
The purpose of this step is to familiarize yourself with the Secondary's account's main domain, Subdomains, Addon Domains, and Aliases. To see a list of the Secondary account's domains, execute the following command:
Code:
uapi --user=account2 DomainInfo list_domains
Code:
# uapi --user=account2 DomainInfo list_domains
---
apiversion: 3
func: list_domains
module: DomainInfo
result:
data:
addon_domains:
- addon2.tld
main_domain: maindomain2.tld
parked_domains:
- alias2.tld
sub_domains: []
errors: ~
messages: ~
metadata: {}
status: 1
warnings: ~
Step 6. Copy the /home/account2/etc/ directory contents
The Secondary account's /home/username/etc/ directory contains the email account passwords, shadow files, and quota files for each domain name added to the account. In this step, we will copy the etc data from the Secondary account into the Master account.
Here's an example of the commands to execute for each domain name listed in the output of Step 5's command:
Code:
cp -a /home/account2/etc/domain1.tld /home/account1/etc/
Step 7. Copy the /home/account2/mail/ directory contents
The Secondary account's /home/username/mail/ directory contains all of the email files for every email account under each added domain. In this step, we will copy the mail data from the Secondary account into the Master account.
Here's an example of the commands to execute for each domain name listed in the output of Step 5's command:
Code:
cp -a /home/account2/mail/domain1.tld /home/account1/mail/
Note: The Secondary account's default email account data (the account2 mail user itself) is not copied as part of the steps in this tutorial.
Step 8. Download MySQL Databases, Email Filters, and Email Forwarders
Access cPanel as the Secondary account's username and browse to cPanel >> Backup. Download each MySQL database, email forwarder, and email filter you see listed.
Then, browse to cPanel >> MySQL Databases and look at the Privileged Users section next to each MySQL database. You'll want to record each database username, the MySQL database it's added to, and the privileges it's assigned (if it's not assigned ALL) to a text file on your local workstation.
Step 9. Copy the directory contents for each domain's document root
Here's an example of the commands to execute to copy the document root for each domain name listed in the output of the command from Step 5 above.
For the Secondary account's main domain (it will become an addon domain):
Code:
cp -a /home/account2/public_html /home/account1/maindomain.tld
Code:
cp -a /home/account2/addon.tld /home/account1/
Code:
cp -a /home/account2/subdomain3.tld /home/account1/
Note that you can define the document root for each domain name when creating them under the Master account in step 15.
Step 10. Copy DNS Zones
Create backups of the DNS zone for each domain names listed in the output of Step 5's command. For example:
Code:
cp -a /var/named/domain.tld.db /var/named/domain.tld.db.backup1
Step 11: Copy Cron Jobs
Access cPanel as the Secondary account's username and browse to cPanel >> Cron Jobs and record the contents/details for each cron job listed in a text file on your local workstation. Then, Access cPanel as the Master account's username, browse to cPanel >> Cron Jobs, and manually add each cron job to the Master account.
Note: Ensure to update the file paths used in any cron job command to reflect the Master account's username.
Step 12. Identify additional data to move
The steps in this tutorial provide instructions on moving the data associated with commonly used accounts and services. Items such as Mailing Lists, Autoresponders, SSL certificates, and PostgreSQL databases are not copied as part of the steps in this tutorial.
As part of this step, make note of any additional data you want to copy in a text file on your local workstation. Step 18 of this tutorial includes information about how to manually extract data from the backup archive generated for the Secondary account should you need to restore it.
Step 13. Update the ownership values for the copied files
The following commands will identify any file under the Master account's home directory owned by the Secondary account's username and update user and group ownership from "account2" to "account1":
Note: Ensure to replace "$account1" with the username of the Master cPanel account and to replace "$account2" with the username of the Secondary cPanel account.
To update the UID:
Code:
find /home/$account1/ -user $account2 -exec chown $account1 {} \;
Code:
find /home/$account1/ -group $account2 -exec chgrp $account1 {} \;
Code:
vi /home/account1/etc/domain123.tld/passwd
Step 14. Terminate the Secondary Account
Browse to WHM >> Terminate Accounts and terminate the Secondary account. Ensure Keep DNS Zone option is not selected. Keep in-mind cPanel & WHM will not serve the terminated account's content or services from the time of termination through the completion of the subsequent account restoration steps documented in this tutorial.
Step 15. Add the domains you recorded as part of Step 5 to the Master Account
A. Access cPanel as the Master account's username and add the Main Domain you recorded as part of Step 5 using cPanel >> Addon Domains.
B. Access cPanel as the Master account's username and add the Addon Domains you recorded as part of Step 5 using cPanel >> Addon Domains.
C. Access cPanel as the Master account's username and add the Aliases you recorded as part of Step 5 using cPanel >> Aliases.
D. Access cPanel as the Master account's username and add the Subdomains you recorded as part of Step 5 using cPanel >> Subdomains.
Ensure you choose document root values that align with the path you copied the document roots to during Step 9.
Step 16. Restore MySQL Databases, Email Filters, and Email Forwarders
Access cPanel as the Master account's username and browse to cPanel >> Backup. Restore each MySQL database, email forwarder, and email filter using the files you downloaded in Step 8.
Note: The command line instructions are available on the link below as an alternative method to use when restoring large MySQL databases: Tutorial - How to import a MySQL database on the command line
Next, browse to cPanel >> MySQL Databases and create the MySQL database users you recorded in a text file to your local workstation in Step 8. Then, add each database user to the corresponding database with the privileges you recorded in the same text file.
It's also important to update the MySQL database credentials in the application's configuration file for any MySQL-based application copied over to the Master account. This includes any changes to the MySQL database name, database user, or the database user's password. Here's an example of where the MySQL configuration data is stored for the WordPress and Joomla applications:
Wordpress - wp-config.php
Code:
define('DB_NAME', 'cptech_wrdp1');
define('DB_USER', 'cptech_wrdp1');
define('DB_PASSWORD', 'PASSWORDHERE');
Code:
public $user = 'cptech_joomla';
public $password = 'PASSWORDHERE';
public $db = 'cptech_joomla';
For each DNS zone you copied as part of Step 10, execute the following commands:
Code:
rm /var/named/domain.tld.db
mv /var/named/domain.tld.db.backup1 /var/named/domain.tld.db
Note: If the IP address assigned to the Master account differs from the IP address you assigned to the Secondary account, use WHM >> Edit DNS Zone for each copied domain and ensure the Master account's IP address is utilized.
Step 18. Copy and extract the Secondary Account's Backup Archive
If you need to import additional data from the Secondary account, execute the following commands to copy and extract it's backup contents to your server's /root directory:
Code:
mkdir /root/backup-copies
cp -a /path/to/cpmove-secondary-account.tar.gz /root/backup-copies/
cd /root/backup-copies/
tar zxvf cpmove-secondary-account.tar.gz
cd cpmove-secondary-account
Step 19. The Two Accounts Are Now Merged Into One
Look over the contents of the Master cPanel account and verify the Secondary account's data was successfully imported. Additionally, now that the two accounts are merged, browse to WHM >> Quota Modification and restore the previous quota value assigned to the Master account.
Additional Questions/Feedback
Feel free to click on the Discussion tab to let us know if you have any questions or feedback about the information in this tutorial.