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

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: [โค้ด] ฟังก์ชัน backup ฐานข้อมูล mysql

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

โดย touleg » 03/05/2011 4:31 pm

โค้ด: เลือกทั้งหมด

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);
} 

ข้างบน