Working with the script furnished down below you will be able to make automated whole cPanel backups of your account.
This backup script involves SSL assist. This is not vital if you operate the script on the server for which you are generating the backup, but the SSL guidance could be crucial if you are running the script somewhere else to join to your cPanel web hosting account.

$cpaneluser="user" // cPanel username $cpaneluserpass="pass" // cPanel password $theme="paper_lantern" // Must match current selected cPanel theme ('paper_lantern' in the majority of cases, 'x3' is possible as well) $ftp = true // Needs to be enabled for the backup to be uploaded to your Namecheap or third-party server do NOT change the value $ftpserver="serverX.web-hosting.com" // Must be 'localhost' for current server or custom hostname for remote FTP upload $ftpusername="user" // cPanel/SFTP username. Should be the same as cPanel username for local upload or custom for remote upload $ftppassword = 'pass' // cPanel/SFTP password. Should be the same as cPanel password for local upload or custom for remote upload $ftpport="21098" // SFTP port. Should be 21 in most cases. $ftpdirectory = '/home/'.$cpaneluser.'/backups' // Directory on FTP server to store backups. MUST EXIST BEFORE BACKUP OR BACKUP PROCESS WILL FAIL. Also, make sure ot update the 'cpaneluser' part with your current cPanel username. // Do not edit below this line $domain = 'localhost' $secure = true $auth = base64_encode($cpaneluser . ":" . $cpaneluserpass) if ($secure) $url = "ssl://" . $domain $port = 2083 else $url = $domain $port = 2082 $socket = fsockopen('localhost', 2082) if (!$socket) exit("Failed to open socket connection.") if ($ftp) $params = "dest=scp&server=$ftpserver&user=$ftpusername&pass=$ftppassword&port=$ftpport&rdir=$ftpdirectory&submit=Generate Backup" else $params = "submit=Generate Backup" fputs($socket, "POST /frontend/" . $theme . "/backup/dofullbackup.html?" . $params . " HTTP/1.0rn") fputs($socket, "Host: $domainrn") fputs($socket, "Authorization: Basic $authrn") fputs($socket, "Connection: Closern") fputs($socket, "rn") while (!feof($socket)) $response = fgets($socket, 4096) // echo $response //uncomment this line for debugging fclose($socket)?>



Note: Make absolutely sure to substitute cPanel user and password with your individual details.


To schedule the script to run regularly, save it as fullbackup.php in your home directory and insert a new cron job with the subsequent syntax:
00 2 * * 1 /usr/regional/bin/php /residence/youraccount/fullbackup.php
(Runs every Monday night at 2:00 a.m.)
In buy to exclude the backups folder from computerized backup generation (if your account is a couple GBs significant, disk room use will raise significantly, as each and every new backup will contain all the former kinds), glance for the cpbackup-exclude.conf file in the house listing, include the folder identify and use an asterisk * right after the directory if you want to exclude all the information from a directory, or insert the path to the file you would like to exclude from backups then and help save the changes.
Be aware: If there is no cpbackup-exclude.conf file in the property listing, you need to have to generate one manually.
NOTES:
- If your account is hosted on a shared server, make certain that your script use is optimized in order not to overload the server.
- We do not present code debugging solutions. This script is provided as a make a difference of courtesy for your advantage only. 

Require any aid? Get in touch with us by way of Helpdesk
Recent Comments