[โค้ด] ฟังก์ชัน backup ฐานข้อมูล mysql

Post a reply

Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: [โค้ด] ฟังก์ชัน backup ฐานข้อมูล mysql

[โค้ด] ฟังก์ชัน backup ฐานข้อมูล mysql

by touleg » 03/05/2011 4:31 pm

Code: Select all

function backup_tables($host,$user,$pass,$name)
{
    $link = mysql_connect($host,$user,$pass);
    mysql_select_db($name,$link);
    mysql_query("SET NAMES utf8");
    
    $backupFile = $name . date("Y-m-d-H-i-s") . '.gz';
    $command = "mysqldump --opt --host=$host --user=$user --password=$pass $name | gzip > $backupFile";
    system($command);
    
    mysql_close($link);
} 

Top