数据库备份的另一种方式,开拓思路。
<?php
$from_dir="D:/MySQL/data/dedecms";
$date = date("Ymd");
$to_dir="D:/bak/dd_" . $date;
if(xCopy($from_dir,$to_dir,1)){
echo '备份完成';
}
function xCopy($source, $destination, $child){
//$child = 1 包括子目录
if(!is_dir($source)){
echo("Error:the $source is not a direction!");
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}
$handle=dir($source);
while($entry=$handle->read()) {
if(($entry!=".")&&($entry!="..")){
if(is_dir($source."/".$entry)){
if($child) xCopy($source."/".$entry,$destination."/".$entry,$child);
}else{
copy($source."/".$entry,$destination."/".$entry);
}
}
}
return true;
}
?>