Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 07:15:47 PM

Pages: 1 ... 7 8 [9]   Go Down
  Print  
Author Topic: Site and MySQL backups via cron  (Read 68966 times)
Abhinandangarg
Spaceship Captain
*****
Offline Offline

Posts: 114


WWW
« Reply #120 on: June 15, 2010, 12:58:03 AM »

It's Really help full for me.. Thanks for sharing here
Logged

weskty22
Newbie
*
Offline Offline

Posts: 1


« Reply #121 on: July 26, 2010, 07:59:34 PM »

great...

thank you for the post..
Logged

8bitkid
Space Explorer
***
Offline Offline

Posts: 8


« Reply #122 on: August 24, 2010, 01:12:20 AM »

i get the following error in the log left on my server:

[23-Aug-2010 23:17:01] PHP Warning:  ftp_put() [<a href='function.ftp-put'>function.ftp-put</a>]: foo.tar.gz: Forbidden filename in /home/nbitkid2/full_backup.php on line 41

any thoughts?
Logged
katrina1
Guest
« Reply #123 on: August 24, 2010, 02:51:28 AM »

The error message says it doesn't like the filename. Change the filename being used.
Logged
8bitkid
Space Explorer
***
Offline Offline

Posts: 8


« Reply #124 on: August 25, 2010, 12:37:21 PM »

the file does have a filename when it is on my server after replication begins.  it is failing at this step:

// upload the file
$upload = ftp_put($ftp_conn, "foo.tar.gz", $filename, FTP_BINARY);
Logged
modctek
Space Explorer
***
Offline Offline

Posts: 6


« Reply #125 on: October 10, 2010, 11:17:16 PM »

I couldn't get the original site backup script at the top of this thread to run without errors, so I made some modifications:

Code:
<?
$datestamp = date("Y-m-d_H-i-s");      // Current date to append to filename of backup file in format of YYYY-MM-DD_HR-MN-SC (hours-mins-secs)

/* CONFIGURE THE FOLLOWING VARIABLES TO MATCH YOUR SETUP */
$filename= "yoursite_backup-$datestamp.tar";   // The name of the dump file
$ftp_server = "111.111.111.111";      // Name or IP. Shouldn't have any trailing slashes and shouldn't be prefixed with ftp://
$ftp_port = "21";   // FTP port - blank defaults to port 21
$ftp_username = "anonymous";      // FTP account username
$ftp_password = "";      // FTP account password - blank for anonymous
$lplogin = "YOURLOGIN"; // Set this to your LP Login name. It will be used in path statements

//  If you don't want to back up your entire directory add additional subdirectories before the star (wildcard).
$command = "tar cvf ~/$filename /home/$lplogin/*";
$result = exec($command);

$command = "gzip -9 -S .gz ~/$filename";
$result = exec($command);

// The filename variable needed to get updated, because your actual backup file got renamed by gzip
// I just decided to create a new variable to hold the final file name.
$finalfile = $filename . ".gz";

// set up basic connection
$ftp_conn = ftp_connect($ftp_server);

// Turn PASV mode on or off

ftp_pasv($ftp_conn, false);

// login with username and password
$login_result = ftp_login($ftp_conn, $ftp_username, $ftp_password);

// check connection
if ((!$ftp_conn) || (!$login_result))
{
   echo "FTP connection has failed.";
   echo "Attempted to connect to $ftp_server for user $ftp_username";
   exit;
}
else
{
   echo "Connected to $ftp_server, for user $ftp_username";
}

// upload the file
// Some changes here from Scanman's original script. Removed the hard-coded "foo" file
// and using the final file name for the destination file.
// note that this uploads the file to $ftp_user's FTP home directory - a personal choice made by me
$upload = ftp_put($ftp_conn, $finalfile, "/home/$lplogin/$finalfile", FTP_BINARY);

// check upload status
if (!$upload)
{
   echo "FTP upload has failed.";
}
else
{
   echo "Uploaded $finalfile to $ftp_server.";
}

// close the FTP stream
ftp_close($ftp_conn);

unlink("/home/$lplogin/$finalfile");   //delete the backup file from the server
?>

Message or email me if you are having trouble with this script. It took me several hours of toying with Scanman's original to get it working for my configuration, so credit to him for the inspiration and framework.
Logged
Earnan
Pong! (the videogame) Master
*****
Offline Offline

Posts: 27


« Reply #126 on: April 09, 2011, 08:46:21 PM »

I am having trouble with the MySQL to FTP. Everything works fine (I end up with  a compressed file), but the file ends after the "USE" command from the first database (line 24).

I have created a database user and added them with SELECT access to all of the databases I want to back up.

I am using:
Code:
$dbname = "--all-databases";      // Database name. Use --all-databases if you have more than one

The first database only as 40,000 records (3mb).

Any ideas why it is not completing the dump but still generating an transmitting a file?

Thanks.

Logged
coolliam
Newbie
*
Offline Offline

Posts: 2


« Reply #127 on: August 01, 2011, 12:16:51 AM »

Hi,

I modify the php script to backup and email a bit to include compress tar file of certain directory, it gives me error "Allowed memory size of 33554432 bytes exhausted (tried to allocate 605 bytes) in.... ". Any thoughts will be appreciated. Thanks.

Code:
$filename2= "files_photos-$datestamp.tar.gz";
$command2 = "tar cvf $filename2 /home/xxx/public_html/abc/photos/";
$result2 = passthru($command2);
$attachmentname2 = array_pop(explode("/", $filename2));
............
$content.= $data."\r\n"; //existing

$content.= "--" . $mime_boundary . "\r\n";
$content.= "Content-Disposition: attachment;\r\n";
$content.= "Content-Type: Application/Octet-Stream; name=\"$attachmentname2\"\r\n";
$content.= "Content-Transfer-Encoding: base64\r\n\r\n";
$content.= $data2."\r\n";
$content.= "--" . $mime_boundary . "\r\n";
Logged
ioudas
Newbie
*
Offline Offline

Posts: 1


« Reply #128 on: August 09, 2011, 05:17:29 PM »

I get this error.



ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Logged
Jerrylou Jones
Newbie
*
Offline Offline

Posts: 2


« Reply #129 on: December 07, 2011, 11:10:39 PM »

Since I'm new here. Thank you for the sites you posted this will helped me.

hammock chair stand
Logged
Pages: 1 ... 7 8 [9]   Go Up
  Print  
 
Jump to: