|
aarste
|
 |
« Reply #105 on: July 17, 2009, 04:01:21 AM » |
|
I've been trying the MySQL backup via cron - Emailed to You and MySQL backup via cron - FTPed to You scripts
but it only emails/ftps a 20 byte backup.sql.gz file, any reason why?
Also another issue I have is crontab doesn't like this script as it outputs this error: /home/morta8/public_html/cronbackupHkS7tt5Cm.php: line 1: ?: No such file or directory /home/morta8/public_html/cronbackupHkS7tt5Cm.php: line 2: syntax error near unexpected token `(' /home/morta8/public_html/cronbackupHkS7tt5Cm.php: line 2: `$datestamp = date("Y-m-d"); // Current date to append to filename of backup file in format of YYYY-MM-DD'
so I have to execute it in my browser instead to my php file and it works (with an empty sql file). Would really like to get this working as the Backup and Restore function in CPanel only backups my site files but not the sql database.
edit: Managed to troubleshoot it a bit further, the cron errors above was due to me not putting a php in front of the /home/morta8/cronbackup.php line. Now that it's working, I have an idea why my sql backup is empty, because cron shows the following: mysqldump: Got error: 1045: Access denied for user 'username-removed'@'localhost' (using password: YES) when trying to connect. I need to be using lpsql01.lunariffic.com as database host as my welcome email says they host the sql on a seperate server.
|
|
|
|
« Last Edit: July 17, 2009, 05:35:50 AM by aarste »
|
Logged
|
|
|
|
|
aarste
|
 |
« Reply #106 on: July 17, 2009, 06:19:55 AM » |
|
I added a new variable among the others: $dbhost = "lpsql01.lunariffic.com"; and adjusted the $command line: $command = "mysqldump --host=$dbhost -u $dbuser --password=$dbpwd $dbname | gzip > $filename"; This is the solution if you have your SQL database hosted on another location other than localhost, hope this helps for people who signed up recently, I'm getting the impression lunarpages used to have the sql database on localhost at the time the script was written 
|
|
|
|
« Last Edit: July 17, 2009, 06:29:17 AM by aarste »
|
Logged
|
|
|
|
axyz1681
Newbie
Offline
Posts: 4
|
 |
« Reply #107 on: July 26, 2009, 07:42:38 AM » |
|
i use MySQL backup via cron - Emailed to You backup my db and my email quota is 20M but my backup fules is over 20M how can i use this to backup my db
|
|
|
|
|
Logged
|
|
|
|
SlvrSurfRidr
Trekkie

Offline
Posts: 12
|
 |
« Reply #108 on: July 26, 2009, 11:37:13 AM » |
|
Login to cPanel, select Mail, edit account, find your account, change the quote to unlimited.
|
|
|
|
|
Logged
|
|
|
|
axyz1681
Newbie
Offline
Posts: 4
|
 |
« Reply #109 on: July 26, 2009, 04:14:58 PM » |
|
Login to cPanel, select Mail, edit account, find your account, change the quote to unlimited.
i use gmail i can not change quota
|
|
|
|
|
Logged
|
|
|
|
Troy L
Support
Galactic Royalty
   
Offline
Posts: 405
Darkwolf
|
 |
« Reply #110 on: July 26, 2009, 05:10:47 PM » |
|
You would only be able to change quotas for email addresses you have with your hosting account.
However, having the sql database email is not really recommended if its more then 2mb or so, as this puts a big strain on the email systems.
In your case, it would be recommended to have the database saved to you hosting account, then you can later download it.
|
|
|
|
|
Logged
|
|
|
|
SlvrSurfRidr
Trekkie

Offline
Posts: 12
|
 |
« Reply #111 on: July 27, 2009, 06:21:40 AM » |
|
Login to cPanel, select Mail, edit account, find your account, change the quote to unlimited.
i use gmail i can not change quota Why are you paying your hosting company for email accounts you aren't using (just wondering). Troy is right though, if it's bigger than 2MB you should seriously consider putting the backup on your server and accessing it when you need it.
|
|
|
|
|
Logged
|
|
|
|
|
laurel2
|
 |
« Reply #112 on: August 06, 2009, 12:12:36 PM » |
|
I'm jumping in here as it's my goal to have my database backed up daily via cron. Being a newbie to cron, I followed the instructions at the beginning of this thread to send backup to email. Here is what I have: <? $datestamp = date("Y-m-d"); // Current date to append to filename of backup file in format of YYYY-MM-DD
/* CONFIGURE THE FOLLOWING SEVEN VARIABLES TO MATCH YOUR SETUP */ $dbuser = "name of my database"; // Database username $dbpwd = "password to database"; // Database password $dbname = "mysql database name"; // Database name. Use --all-databases if you have more than one $filename= "backup-$datestamp.sql.gz"; // The name (and optionally path) of the dump file $to = "support@money-recycler.com"; // Email address to send dump file to $from = "support@money-recycler.com"; // Email address message will show as coming from. $subject = "MySQL backup file"; // Subject of email
$command = "mysqldump -u $dbuser --password=$dbpwd $dbname | gzip > $filename"; $result = passthru($command);
$attachmentname = array_pop(explode("/", $filename)); // If a path was included, strip it out for the attachment name
$message = "Compressed database backup file $attachmentname attached."; $mime_boundary = "<<<:" . md5(time()); $data = chunk_split(base64_encode(implode("", file($filename))));
$headers = "From: $from\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: multipart/mixed;\r\n"; $headers .= " boundary=\"".$mime_boundary."\"\r\n";
$content = "This is a multi-part message in MIME format.\r\n\r\n"; $content.= "--".$mime_boundary."\r\n"; $content.= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $content.= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $content.= $message."\r\n"; $content.= "--".$mime_boundary."\r\n"; $content.= "Content-Disposition: attachment;\r\n"; $content.= "Content-Type: Application/Octet-Stream; name=\"$attachmentname\"\r\n"; $content.= "Content-Transfer-Encoding: base64\r\n\r\n"; $content.= $data."\r\n"; $content.= "--" . $mime_boundary . "\r\n";
mail($to, $subject, $content, $headers);
unlink($filename); //delete the backup file from the server ?>
And this is the error that keeps coming to my email address: <br /> <b>Warning</b>: Unexpected character in input: ' ' (ASCII=11) state=1 in <b>/home/account_name/public_html/domain_folder_name/cron_backup_script.php</b> on line <b>1</b><br /> <br /> <b>Parse error</b>: syntax error, unexpected T_STRING in <b>/home/nasrinc3/public_html/money-recycler/cron_backup_script.php</b> on line <b>1</b><br />
Am wondering, should "localhost" be somewhere in the string? Am lost................. Thanks, Patsy
|
|
|
|
|
Logged
|
|
|
|
|
|
marissa
Trekkie

Offline
Posts: 16
|
 |
« Reply #114 on: December 04, 2009, 02:23:18 AM » |
|
MySQL Backup: A user's guide to backup and recovery in MySQL. ... Consider the following shell script, named backup.sh, run on a Linux box via crontab: .... As you can see, the program is able to handle backups of both MyISAM and InnoDB tables.....
Thanks ...
|
|
|
|
|
Logged
|
|
|
|
cronides
Newbie
Offline
Posts: 3
|
 |
« Reply #115 on: January 27, 2010, 12:06:16 PM » |
|
Using the MySql FTP script I am able to run it under Public_HTML to test without a path and the file uploads to the home directory. Trying to use this filename with path: $filename= "/home/EDITED/phpscriptbackup/doc/backup-$datestamp.sql.gz"; I get this error: Connected to willow.lunarbreeze.com, for user EDITED@osagecollies.com Warning: ftp_put() [function.ftp-put]: Rename/move failure: No such file or directory in /home/EDITED/public_html/phpscriptbackup/phpbackup.php on line 41 FTP upload has failed.The directory structure exists and has world write permissions (777) on both the phpscriptbackup folder and the doc folder within it. Am I missing something on the filename path? Thanks! *edited for username
|
|
|
|
« Last Edit: January 27, 2010, 12:58:14 PM by Troy L »
|
Logged
|
|
|
|
Troy L
Support
Galactic Royalty
   
Offline
Posts: 405
Darkwolf
|
 |
« Reply #116 on: January 27, 2010, 01:07:37 PM » |
|
As Lunarpages uses suPHP , you may want to change all folders and the file to permissions of 755 . Generally settings of 777 will not work in most cases.
You will also want to insure that you are using the correct/complete database information for the database name, username, and password.
As the issue appears to be in " on line 41 " of " /home/EDITED/public_html/phpscriptbackup/phpbackup.php " you may want to view what exactly in the script is being called, and if its a file that does exist, double check the permissions.
|
|
|
|
|
Logged
|
|
|
|
cronides
Newbie
Offline
Posts: 3
|
 |
« Reply #117 on: January 27, 2010, 01:36:32 PM » |
|
As Lunarpages uses suPHP , you may want to change all folders and the file to permissions of 755 . Generally settings of 777 will not work in most cases.
You will also want to insure that you are using the correct/complete database information for the database name, username, and password.
As the issue appears to be in " on line 41 " of " /home/EDITED/public_html/phpscriptbackup/phpbackup.php " you may want to view what exactly in the script is being called, and if its a file that does exist, double check the permissions.
I went back and changed to 755 on both folders and got the same error. All the db information is correct and the script works fine if I don't put a path in the filename: For example, if I use this instead: $filename= "backup-$datestamp.sql.gz"; // The name (and optionally path) of the dump file It creates the backup file fine and places it in my home directory. While that is functional, I'd rather the backup be placed in a particular directory for organizations sake. Line 41 of the script (the one that started the post) is: $upload = ftp_put($ftp_conn, $filename, $filename, FTP_BINARY); Thanks for the help. Edit: Ugh... ok, I take it back, it IS creating the file without the path but the file is not "fine" per say. It has no data. 
|
|
|
|
« Last Edit: January 27, 2010, 01:43:36 PM by cronides »
|
Logged
|
|
|
|
Troy L
Support
Galactic Royalty
   
Offline
Posts: 405
Darkwolf
|
 |
« Reply #118 on: January 27, 2010, 08:08:24 PM » |
|
Just in case, are you on a Cpanel server, plesk server (windows) or a LPCP server?
|
|
|
|
|
Logged
|
|
|
|
cronides
Newbie
Offline
Posts: 3
|
 |
« Reply #119 on: January 27, 2010, 08:23:33 PM » |
|
Server: Willow. I use cpanel.
|
|
|
|
|
Logged
|
|
|
|
|