<?php
$link = mysql_connect($host,$user,$pass);
mysql_select_db($database_name,$link);
$tableName = '(select * from table_name where date(created_at) = "2013-09-04")';
//$tableName = 'table_name';
$backupFile = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR.'backup.sql';
$query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
$result = mysql_query($query);
echo "backup complete";
mysql_close($link);
$link = null;
?>
Restore table script
<?php
$link = mysql_connect($host,$user,$pass);
mysql_select_db($database_name,$link);
$tableName = 'table_name';
$backupFile = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR.'backup.sql';
$query = "LOAD DATA INFILE '$backupFile' INTO TABLE $tableName";
$result = mysql_query($query);
echo "backup restore complete";
mysql_close($link);
$link = null;
?>