Go Back   SolidHost Forums Support Forums Tutorials / How to?

Reply
 
Thread Tools Display Modes
Old Jun 5th, 2005, 22:57   #1
dnc
Customer
 
Join Date: Nov 2004
Posts: 45
Default Cron full backup and save to remote ftp server

Here is a script I use successfully for more than 5 months. I found it somewhere in the net and it is really great.

PHP 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 "user"// Username used to login to CPanel
$cppass "pass"// Password used to login to CPanel
$domain "domain.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 "ftp_user"// Username for FTP account
$ftppass "ftp_pass"// Password for FTP account
$ftphost "ftp_host"// Full hostname or IP address for FTP host
$ftpmode "ftp"// FTP mode ("ftp" for active, "passiveftp" for passive)

// Notification information
$notifyemail "email@domain.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);

?>
I have a question for the SH admin:
- is it better to use ftp or passive ftp for the tranfer on the remote host? Speaking of speed and mainly on load on the server.
dnc is offline   Reply With Quote
Old Jul 1st, 2005, 16:07   #2
CPUBum
Customer
 
Join Date: Feb 2005
Location: Virginia
Posts: 44
Default

This is nice... I will have to try it out and see if it will FTP to my home location for some of my critical sites... Even though I backup to a seperate drive in my server, still nice to have another backup elsewhere
CPUBum is offline   Reply With Quote
Old Oct 26th, 2005, 15:03   #3
CPUBum
Customer
 
Join Date: Feb 2005
Location: Virginia
Posts: 44
Default

Another way to do remote backups is to create a script that runs /scripts/pkgacct $1 where $1 is the accout you want backed up. This will create a tar of the entire site that can be placed into the /home directory and restored from WHM ROOT. It packages up everything you need to do a complete restore. In the script have it FTP the file to another remote location. Then you just cron the script that does this backup and FTP. That way you do not need to have any passwords or user ID's sitting in files on the server that in text format.
CPUBum is offline   Reply With Quote
Old Mar 23rd, 2010, 08:47   #4
Alexanderjhon
Customer
 
Join Date: Mar 2010
Posts: 10
Default Hi,

I have been reading through your site, finding it very interesting.
Alexanderjhon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 01:36.