Hi
I've joined this forum soley to say thanks for the above script. I now use it to backup my databases to drivehq as an offsite copy. I had previously backed up to my root, but wanted something a bit safer, so I asked a guy at ScriptLance to amend the code so it would save to drivehq's site in passive ftp mode (the only way to save stuff there, apparently).
Anyway, I thought I'd share the amended code in case someone else found it useful. Thanks again to the brockhosting poster. Here's the new version (including the corrected spelling):
<?
// A script produced by BrockHosting.com
// For more help visit h**p://www.brockhosting.com/bb/viewtopic.php?p=13
$user_name = "yourusernamehere"; // YOUR cpanel user name
$user_pass = "yourpasswordhere"; // YOUR cpanel password
$user_website = "www.yourwebsitehere.com"; // YOUR website do NOT include http://
$ftp_server_ip = "ftp.drivehq.com"; // Server IP here
$ftp_server_user = "yourusernamehere"; // FTP login name here
$ftp_server_pass = "yourpasswordhere"; // FTP password here
$db_list = array("phpbb1","ptp","rcash"); // List of your databases
// Must be "database1","Database2"
// DO NOT ENTER "username_database1", "username_database2"
// Do not edit below this line
$dc = time();
$looper = 0;
while($db_list[$looper] != null) {
$db_name = $db_list[$looper];
$get_this = "http://".$user_name.":".$user_pass."@".$user_website.":2082/getsqlbackup/".$db_name.".gz";
echo "\n<br><br>\nAttempting to download $db_name";
$handle = fopen($get_this, "r");
$save_as = "backup_".$db_name."_".$dc."_.gz";
if ($handle != null) {
$local_handle = fopen($save_as,"x");
echo "\n<br>Saving \"$db_name\" as \"$save_as\" ";
while(!feof($handle)){ fwrite($local_handle,fgets($handle)); }
}
fclose($handle);
fclose($local_handle);
// Got file need ftp home
$ftp_conn_id = ftp_connect($ftp_server_ip) or die("Couldn't connect to $ftp_server_ip");
ftp_login($ftp_conn_id, $ftp_server_user, $ftp_server_pass);
$passive = ftp_pasv ($ftp_conn_id, true );
$upload = ftp_put($ftp_conn_id, $save_as, $save_as, FTP_BINARY);
if ($upload != null) {
echo "\n<br>File Sent!\n";
unlink($save_as);
} else {
echo "\n<br>File NOT SENT!\n";
}
ftp_close($ftp_conn_id);
$looper++;
}
?>