| Author |
Message |
darksied Hangin' Around

Joined: Jan 27, 2004 Posts: 25 Location: New Jersey
|
Posted:
Wed May 12, 2004 8:12 am |
|
Ok this many not be the proper venue for this but i will take a chance. i think we all need a way to automate the back up of our domains with out always going in to cpanel so i did a search and this is what i found. and i dont know who the orignal author is so i cant give credit were credit is due.
| Code: | <?php
// 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 = "monsoon"; // 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);
?> |
Now i have tried this manually executing the php page via the web browser but all i get is a blank page and no backed up domain can anyone shed light on this as to what may be wrong. i am not a php programer but i am trying to learn when time allows,
ps the reason i posted this is that i feel it could be some thing we all can use to make our lives a bit easer  |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Wed May 12, 2004 9:58 am |
|
Keep in mind that your site should be automatically backup every day by your host. If it is not, head on over to Raven Web Hosting  |
Last edited by Raven on Wed May 12, 2004 10:57 am; edited 1 time in total |
|
|
 |
darksied Hangin' Around

Joined: Jan 27, 2004 Posts: 25 Location: New Jersey
|
Posted:
Wed May 12, 2004 10:37 am |
|
No i understand that but what i have is a resellers account that does not have the backup config enabled in the WHM and i host a few sites particularly one for a maaco autobody shop. what is do now is a manualy backup of all five sites in cpanel on a sunday and then manually ftp them to my local machine. i have had a instance where a site was restored by my host and it was a mess i figured instead of doing this manually for every site i could semi automate it.
i have heard that there is a way to get a cron job to do it but i have googled till my fingers hurt and called a few admins i know and no one seems to be able to point me in the right direction or supply me with a good working sample. i just want some redundancy in case of a mishap on the hosts end and peice of mind thats all |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Wed May 12, 2004 1:52 pm |
|
Yeah really your once a week file backups is even overkill in a way unless there is really files changing that often (photo uploads or something). You could run the mysql backup from a cron job providing your host allows it (Some don't). This would be a lot more efficient even if you do a daily backup. Even if they don't there are a ton of php scripts that will do it as a cron job.
About the script did you try setting the debug function on yet? If so what was the result. |
|
|
|
 |
darksied Hangin' Around

Joined: Jan 27, 2004 Posts: 25 Location: New Jersey
|
Posted:
Wed May 12, 2004 10:24 pm |
|
No i did not set the debug function because i dont know how to do that any help would be appreciated in that area. as far as a php scripts that will do as a cron job i looked on php resource.com but i must have missed it can you suggest some where else to look. thanks for the help  |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu May 13, 2004 5:15 am |
|
Ok the script looks very simple if there is something going wrong it is like either a wrong username pass or some of the url is slightly different in your system.
The cpanel theme is one of the settings did you get that part setup? The debug you just change to 1 in the config part. Most likely FTP mode has to be set to passive. I'd verify the actual url to the backup function in Cpanel. |
|
|
|
 |
|
|
|
|