Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
darksied
Hangin' Around



Joined: Jan 27, 2004
Posts: 25
Location: New Jersey

PostPosted: Wed May 12, 2004 8:12 am Reply with quote

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 Wink
 
View user's profile Send private message Visit poster's website AIM Address
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Wed May 12, 2004 9:58 am Reply with quote

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 Wink


Last edited by Raven on Wed May 12, 2004 10:57 am; edited 1 time in total 
View user's profile Send private message
darksied







PostPosted: Wed May 12, 2004 10:37 am Reply with quote

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: 2496

PostPosted: Wed May 12, 2004 1:52 pm Reply with quote

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.
 
View user's profile Send private message
darksied







PostPosted: Wed May 12, 2004 10:24 pm Reply with quote

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 Mr. Green
 
sixonetonoffun







PostPosted: Thu May 13, 2004 5:15 am Reply with quote

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.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©