分类:
2008-05-29 08:47:45
set_time_limit(36000); $orders = 9; //目标表序号 $dbNames = array("seeditbbs","seedblog"); //备份多库 $con = mysql_connect("localhost","root","h67g4n9s8l"); //h67g4n9s8l mysql_select_db("seeditbbs",$con); $rs = mysql_query("SHOW GLOBAL VARIABLES"); //读取MYSQL系统变量 while($row = mysql_fetch_row($rs)){ if($row[0]=="datadir"){ $dataDir = $row[1]; //得到MYSQL的DATA目录 mysql_free_result($rs); break;} } foreach($dbNames as $dbName){ //循环备份多库 $fromDir = $dataDir; $toDir = "i:/db_bak/{$dbName}{$orders}/"; //目标目录 if(!is_dir($toDir)) mkdir($toDir ); //建保存目录 $fromDir .= "{$dbName}/"; //源目录 $dirArr = scandir($fromDir); foreach($dirArr as $subFile){ //拷备所有表文件 if()) copy($fromDir.$subFile,$toDir.$subFile); } } ($orders<9) ? $orders++ : $orders=1; //表序号自增,一日9次,备份时间: 1 8 10 12 14 16 18 20 22 $file = file_get_contents($_SERVER["SCRIPT_FILENAME"]); $file = preg_replace("|\\\$orders \= \d+|","\$orders = $orders",$file); //修改本文件目标表序号 file_put_contents($_SERVER["SCRIPT_FILENAME"],$file); //保存?> |