Copying Add-on Domains to Your New Accounts (part 1)
Posted by Alex on 02 01 2017.
When you want to create an add-on domain, you can do by creating an entirely new account from that newly created domain. It is quite simple to perform this task: just copy all the data from your new domain to your new account.
For cPanel & WHM version 56 (or newer) users, the steps indicated here does not apply. You can simply use the “Convert Addon Domain to Account” interface in your WHM account. Just navigate to Home then Transfers then Convert Addon Domain to Account.
Since copying add-on domains to new accounts require the action of moving files, only the highest-level user, known as the root user, can perform it. Resellers with root-level authorization also have this privilege.
There are four keywords you need to remember when conducting this task:
- Username – pertains to the account user.
- Newusername – pertains to the new account’s user.
- Addonname – pertains to the add-on domain’s name.
- Addonfolder – pertains to the add-on domain’s folder.
To start copying add-on domains to new accounts, here are the steps you should follow:
- Backup creation.
First, you should create a complete backup of the account for the specific add-on domain. You can simply do this through the Backups interface of cPanel, found at Home – Files – Backups.
You can also opt to execute the command: /scripts/pkgacct script.
- New account creation.
Next, you need to make a new account. You have to use a placeholder name for this, via WHM’s interface. Just use the “Create a New Account” interface found in your WHM account by navigating through Home – Account Functions – Create a New Account.
Make sure that, for the new account your will create, you will not use the name of the add-on domain.
- Backup extraction.
Third step is to perform a backup extraction – the same backup you just created. Just follow these steps:
- Create the directory titled: /home/backup-username, where the term “username” refers to the account name. Running the command “mkdir /home/backup-username” (without the quotation marks) will complete this process.
- Then, open your /home directory, navigate to the /home/backup-username directory, and finally, place your backup file in it. Run the command: mv cpmove-username.tar.gz /home/backup-username/ to complete this part.
- You then need to uncompress your backup. Just run this command to do this: “tar -xzf cpmove-$username.tar.gz” (again, disregarding the quotation marks). This is important as the command extracts your backup either to the username or the cpmove-username directory.
- Click on the directory to open it, navigate to /home/newusername/public_html/ directory, and then place the homedir/public_html/addonfolder/ subdirectory in it. To complete this part, just execute the command: “cp -R homedir/public_html/addonfolder/* /home/newusername/public_html/” (do not include the quotation marks).
- Database importing.
For the fourth step of this two-part document for copying add-on domains to new accounts, you need to perform database importing.
To do this, just follow these steps:
- Recreate or make copies of the databases of your addon domain. Do the same for your database users. Do this by navigating to Home- Databases – MySQL Databases. Do not forget to prepend “newusername” to each of the databases you created. It should look something like this: “$newusername_dbname” (excluding the quotation marks).
- Once you are done, you can now import every one of the database backups of the domain. Just run this command for each of your backups: “mysql $newaccount_dbname < /home/backup-$username/$username/mysql/$username_dbname.sql” (remove the quotation mark).