tag:blogger.com,1999:blog-7351720777864100444.post935507206394864445..comments2023-10-18T17:10:09.470+08:00Comments on EasyCron Official Blog: A simple PHP script to periodically backup mysql databaseUnknownnoreply@blogger.comBlogger8125tag:blogger.com,1999:blog-7351720777864100444.post-76256128320990377092020-04-10T20:00:39.577+08:002020-04-10T20:00:39.577+08:00This works for me. did some tweak. But everything ...This works for me. did some tweak. But everything is fine. Backing up remote mysql db. :)Adminhttps://www.blogger.com/profile/15236860163085805393noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-8003267401155627442018-03-09T00:48:39.773+08:002018-03-09T00:48:39.773+08:00Um código que funciona em Windows (A code that wor...Um código que funciona em Windows (A code that works in Windows:<br /><br />Tiago França,<br />Fonte/Source:http://www.howi.in/2016/12/auto-backup-mysql-database-using-php.html<br /><br /><br /><br /><br /><br />select_db($name);<br /> $mysqli->query("SET NAMES 'utf8'");<br /><br /> $queryTables = $mysqli->query('SHOW TABLES');<br /> while($row = $queryTables->fetch_row())<br /> {<br /> $target_tables[] = $row[0];<br /> }<br /> if($tables !== false)<br /> {<br /> $target_tables = array_intersect( $target_tables, $tables);<br /> }<br /> foreach($target_tables as $table)<br /> {<br /> $result = $mysqli->query('SELECT * FROM '.$table);<br /> $fields_amount = $result->field_count;<br /> $rows_num=$mysqli->affected_rows;<br /> $res = $mysqli->query('SHOW CREATE TABLE '.$table);<br /> $TableMLine = $res->fetch_row();<br /> $content = (!isset($content) ? '' : $content) . "\n\n".$TableMLine[1].";\n\n";<br /><br /> for ($i = 0, $st_counter = 0; $i < $fields_amount; $i++, $st_counter=0)<br /> {<br /> while($row = $result->fetch_row())<br /> { //when started (and every after 100 command cycle):<br /> if ($st_counter%100 == 0 || $st_counter == 0 )<br /> {<br /> $content .= "\nINSERT INTO ".$table." VALUES";<br /> }<br /> $content .= "\n(";<br /> for($j=0; $j<$fields_amount; $j++)<br /> {<br /> $row[$j] = str_replace("\n","\\n", addslashes($row[$j]) );<br /> if (isset($row[$j]))<br /> {<br /> $content .= '"'.$row[$j].'"' ;<br /> }<br /> else<br /> {<br /> $content .= '""';<br /> }<br /> if ($j<($fields_amount-1))<br /> {<br /> $content.= ',';<br /> }<br /> }<br /> $content .=")";<br /> //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler<br /> if ( (($st_counter+1)%100==0 && $st_counter!=0) || $st_counter+1==$rows_num)<br /> {<br /> $content .= ";";<br /> }<br /> else<br /> {<br /> $content .= ",";<br /> }<br /> $st_counter=$st_counter+1;<br /> }<br /> } $content .="\n\n\n";<br /> }<br /> //$backup_name = $backup_name ? $backup_name : $name."___(".date('H-i-s')."_".date('d-m-Y').")__rand".rand(1,11111111).".sql";<br /> $date = date("Y-m-d_H:i:s");<br /> $backup_name = $backup_name ? $backup_name : $name.".$date.sql";<br /> header('Content-Type: application/octet-stream');<br /> header("Content-Transfer-Encoding: Binary");<br /> header("Content-disposition: attachment; filename=\"".$backup_name."\"");<br /> echo $content; exit;<br /> }<br />?>Anonymoushttps://www.blogger.com/profile/02105707237712155575noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-5712230160493401062017-07-26T10:39:20.500+08:002017-07-26T10:39:20.500+08:00Using crontab, you could add this:
12 0 * * * /usr...Using crontab, you could add this:<br />12 0 * * * /usr/bin/php PATH_TO_YOUR_BACKUP_PHP_SCRIPT<br /><br />Otherwise, you could just place the backup php script on your web server, and add a URL pointing to it on easycron to trigger it.adminhttps://www.blogger.com/profile/01187374704723963564noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-61083951164787562582017-07-25T21:44:13.003+08:002017-07-25T21:44:13.003+08:00Pls share the appropriate cronjob command...Pls share the appropriate cronjob command...Manafhttps://www.blogger.com/profile/11691976319760090284noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-62137347398331020632017-04-14T15:23:43.017+08:002017-04-14T15:23:43.017+08:00Yes, it worked. I run the script manually.
can you...Yes, it worked. I run the script manually.<br />can you please tell me what command i have to put in cronjob command box?Geony Jacobshttps://www.blogger.com/profile/11380364514189995089noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-91512671645762933542016-09-06T20:00:13.599+08:002016-09-06T20:00:13.599+08:00hahhahMubarhttps://www.blogger.com/profile/09628727993983302711noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-76100557134910029922016-07-20T22:21:26.183+08:002016-07-20T22:21:26.183+08:00We hope we can keep the comments. But unfortunatel...We hope we can keep the comments. But unfortunately all comments are just SPAMs saying "Want PHP training? Access http://xxxxx" :(adminhttps://www.blogger.com/profile/01187374704723963564noreply@blogger.comtag:blogger.com,1999:blog-7351720777864100444.post-86461801778390725222016-07-20T15:52:18.805+08:002016-07-20T15:52:18.805+08:00Why have you remove comments? That does not give c...Why have you remove comments? That does not give confidenceAnonymoushttps://www.blogger.com/profile/03415776138927594062noreply@blogger.com