PHP数据库备份到桌面

//半自动

function copydb($name){

//以PHPstudy为例 安装在F盘

            $oldPath = "F:\phpStudy\MySQL\data\\".$name;

            $deskPath = getDesktopPath().$name;

//创建数据库文件夹

            exec("mkdir ".$deskPath);

//备份操作

           $string = " xcopy ".$oldPath." ".$deskPath." /e";

           exec($string,$out);

}

//获取桌面路径 得到用户名

function getDesktopPath(){

          $dir = "C:\Users";

          $arry = scandir($dir);

//排除默认角色,文件

          $scanned_directory=array_diff($arry,array('..','.','All Users','Default','Default User','Public','desktop.ini'));

          $deskpath="";

 //取出用户名

          foreach($scanned_directory as $path )  {

               $deskpath=$path;

       }

        $desktopPath = "C:\Users\\".$deskpath."\Desktop\\";

        return $desktopPath;

}

copydb("boolib");

你可能感兴趣的:(PHP数据库备份到桌面)