Who's going to help? Modify the current code backup MySQL PHP code requires backup to local

Source: Internet
Author: User
Tags create directory
Who's going to help? Modify the current code backup MySQL PHP code requires backup to local
I use the web-based PHP backup MySQL data code, the article title is: Back up the MySQL database PHP code (a table a file). The code at the bottom of the post.

But now can only back up to the directory of the virtual host, now I need to only back up to the local directory, such as the local computer D drive a folder. Virtual host does not do anything, because I bought a charge of the virtual host, long-term cost, plus I php initial stage, slightly complex code will not be modified.

Everyone to see if you can modify the code, as long as the local backup. Or do not modify also can provide me with the same function of the code file, thank you.

PHP Code
  
  Date: ". Date (' Y-n-j h:i:s ')."
ERROR: ". $info."
SQL: ". $sql."
}
"; } Public function Close () {self:: $DB =null,} public Function __destruct () {self::close ();}} /*---class end*/function MakeDir ($dirpath) {if (! $dirpath) return 0; $dirpath =str_replace ("\ \", "/", $dirpath); $mdir = "" ; foreach (Explode ("/", $dirpath) as $val) {$mdir. = $val. " /"; if ($val = = "..." | | $val = = ".") Continue if (!is_dir ($mdir) &&!file_exists ($mdir)) {if ([email protected] ($mdir, 0755)) {exit ("Create directory [". $mdir. "] Failed. ");}} return true; } function Deldirandfile ($dirName) {if ($handle =opendir ($dirName)) {while (false!== ($item = Readdir ($handle))) {if ($ Item! = "." && $item! = "...") {if (Is_dir ("$dirName/$item")) {Deldirandfile ("$dirName/$item");} else{unlink ("$dirName/$item");}} } closedir ($handle); if (RmDir ($dirName)) echo "Successfully deleted directory: $dirName
\ n "; }} function Filein ($filename = "databak/", $table = ' ', $mysql = ') {$fp = fopen ($filename. ') /'. $table. '. SQL ', ' W '); Fputs ($fp, $mysql); Fclose ($FP); } header ("Content-type:text/html;charset=utf-8"); $db =new dbmysql (); $table = $db->gettablesname (); $filename = "databak/". Date ("Ymd"); $url =getcwd (). " /databak/"; $handle = Opendir ($url); while (false!== ($file = Readdir ($handle))) {if ($file! = ".") && $file! = "..." &&is_dir ($url. " /". $file)" {if (date ("YMD")-$file >5) {deldirandfile ($url. ") /". $file);}; }} makedir ($filename); foreach ($table as $t) {$s 1= $db->fetch_array ("Show create Table ' $t '"), $mysql = "/*time:". Date ("Y-m-d h:i:s"). "*/\r\ Ndrop table IF EXISTS ' $t '; \ r \ n ". $s 1[' Create TABLE ']."; R\n\r\n "; $a 1= $db->FETCH_ASSOC ("select * from ' $t '"); foreach ($a 1 as $data) {$vals =array_values ($data); $vals =array_map (' addslashes ', $vals); $vals =join ("', '", $vals); $ Vals= "'". $vals. "'"; $mysql. = "INSERT into ' $t ' VALUES ($vals); \ r \ n"; } $mysql. = "\ r \ n"; Filein ($filename, $t, $mysql); } echo "numberThe backup file was generated ". GETCWD ()." /". $filename." /
The program automatically cleans up backups from 5 days ago ";?>
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.