This script helps to transfer cPanel accounts between servers with the reseller access level. It can be used in the following transfer cases:
- reseller – reseller
- root – reseller (If we do not have SSH access to the source server; as a result, WHM’s Transfer Tool cannot be used)
- reseller – root (obviously, we will not be able to use the Transfer Tool here)
The script has got several options:
- Show pre-transfer information (inode/disk usage, SSL сertificates and basic cPanel server configuration) using cPanel API
- Generate cPanel backups via cPanel API and upload them to the reseller’s home directory via FTP
- Generate cPanel backups using a direct URL (‘dofullbackup.html’ will be used)
- Acquire information about our reseller (disk usage, disk usage for email, inode usage). You may need this option, if you are going to transfer only one or a few cPanel accounts (obviously, you will be doing this manually) and you just need to make sure the reseller’s package can host those additional accounts.
The script is very easy to use, though I am providing a basic tutorial with pictures below.
- Download the script:
- Make it executable:
chmod +x cpbackup.sh
- Create an alias for it in .bashrc (I used the
alias cpb='bash $HOME/scripts/cpbackup.sh')
Alright, so, now that you have downloaded the script, let us set it up and run on our terminal server.
- Entering login details. Before running the script, you need to open it and enter the source and the destination login details. If you are going to perform a bulk transfer, fill in the ‘RESELLER TRANSFER SCRIPT’ form. If you just need to check our reseller, then fill in the ‘NC RESELLER RESOURCE USAGE SCRIPT’ form. One should pay attention to the “sleep” parameter; it means a delay (in seconds). Basically, it means how many seconds the script will wait before starting to create a new backup. The backup creation process depends on server resources and server load. So, if a server is creating several large backups simultaneously, the result would depend on the two aforementioned parameters. If the server does not have enough resources, some of the backups can simply time out. Decrease the sleep value, if you have small cPanel accounts, or increase it, if you have large accounts. The default value is set to 180 seconds; this should be enough in most cases.
- Creating the transfer list. If you have a list of accounts that need to be transferred, or if you have a list of accounts that need to be excluded from the transfer, create a file named “list” on your machine and put the cPanel usernames in it (usernames should be entered in a column – one username per line). If you want to transfer all the cPanel accounts of a reseller, just skip this step 🙂
- Running the script. Run the script from Bash:
bash cpbackup.sh. Or, use your alias created earlier.
3.1 If you have the “list” file with included/excluded accounts, you will see the following menu:
3.2 If you do not have “list”. the following menu will show up:
Let us see what the script’s output looks like. If you select the option to show pre-transfer information, then you will see the following table:
After the check has completed, you will see a summary like the one provided below:
The backup creation progress looks as follows:
After the script has finished its work, some backups may still be uploading or waiting their turn to be created. You can check the uploaded/uploading/not uploaded accounts by running this command:
bash cpbackup.sh --check, or with the alias:
That is it!