cpanel backup scripts

RobAPI

New member
Hello
Could anyone tell me where I can get a script to backup everything on my server please?
I am running cPanel and I don't think the cPanel backup does everything, I would like to have it so if anything happens on my server I can have it restored to exactly how it was before.
This is just for a personal server and I would like all settings to be saved somewhere incase something does happen.

Thanks
 
Don't mean the actual cpanel backup, that is automatic but it only backups up some things, databases, account files and email.
But I would like something that backs up the config of the server itself so I can have it back to normal if anything ever does happen.
 
Robapi,


Here is a script that will allow you to automate your cpanel backup through cron jobs.


Be aware though that this script is a potential security hole because you are passing your login and password information in the clear through an http connection.


ABSOLUTELY keep this script out of your public_html directory.

Code:
// PHP script to allow periodic cPanel backups automatically.
// Based on script posted by max.hedroom in cpanel.net forums
// This script contains passwords. KEEP ACCESS TO THIS FILE SECURE!

// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

// Info required for cPanel access
$cpuser = "username"; // Username used to login to CPanel
$cppass = "password"; // Password used to login to CPanel
$domain = "example.com"; // Domain name where CPanel is run
$skin = "x"; // Set to cPanel skin you use (script won't work if it doesn't match)

// Info required for FTP host
$ftpuser = "ftpusername"; // Username for FTP account
$ftppass = "ftppassword"; // Password for FTP account
$ftphost = "ftp.example.com"; // Full hostname or IP address for FTP host
$ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)

// Notification information
$notifyemail = "you@example.com"; // Email address to send results

// Secure or non-secure mode
$secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP

// Set to 1 to have web page result appear in your cron log
$debug = 0;

// *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********

if ($secure) {
$url = "ssl://".$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}

$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connection... Bailing out!\n"; exit; }

// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);

$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&submit=Generate Backup";

// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
fputs($socket,"Host: $domain\r\n");
fputs($socket,"Authorization: Basic $pass\r\n");
fputs($socket,"Connection: Close\r\n");
fputs($socket,"\r\n");

// Grab response even if we don't do anything with it.
while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;
}

fclose($socket);

?>

Remember to put the file with this code in your "home" directroy - not in "public_html".
And CHMOD it 600.
Then create the cron job, like this;

5 2 * * 6 /usr/local/bin/php /home/username/fullbackup.php
(=2.05 am saturday)
 
RobAPI you should take a look at LiquidWeb's backup servers. They provide you some space / bw and a cool little script which you can use from your own home to remote into both locations and do either full/partial backups. It is kind of pricey.... but an offsite backup is a very good idea.

You could always pay an extra $15 a month to get a 40GB drive installed as a slave. Then write a cronjob that will copy from one drive to the other.
 
Hey,
Thanks for that fallcreek (Is it John you are called?) but it looks like it only uses the full backup for cPanel and doesn't backup any of the server config.
I am able to do a backup from cPanel to a remote server or another hard disk, but I would also like the server config backed up and the config for all scripts and services installed and running.

I have never seen anything for this and not sure if it exists but I am just after something that will backup everything needed to do a full restore on the server if anything serious was to ever go wrong, so nothing at all would be lost.
Kind of like what a system restore would do on Windows now that I think about it..
 
Sorry about that, RobAPI,

Now that I look back over your messages, I see that I misunderstood your request.

You're right, this just automates the cPanel backup.

Try going to cpanel.net, the forums there usually have quite a lot of information on backups.

John
 
Back
Top