Which of the following experts can help you modify the current code to back up mysql's php code and request it to be backed up locally?

Source: Internet
Author: User
Which of the following experts helped me modify the current code to back up mysql php code and asked me to back up it to a local location? I used php code circulating on the Internet to back up mysql data. The title of this article is: back up the php code of the mysql database (one table and one file ). The code is pasted at the bottom, but now it can only be backed up to the virtual host Directory. now I only need to back up to the local directory, such as a folder on the local computer D drive. No one on the VM can help you modify the current code to back up the php code of mysql.
I used php code circulating on the Internet to back up mysql data. The title of this article is: back up the php code of the mysql database (a table and a file ). Bottom of the code

But now I can only back up to the virtual host Directory. now I only need to back up to the local directory, such as a folder on the local computer D drive. The VM does not perform any operation, because I buy a charged VM and it will not be able to afford long-term expenses. in addition to my php initial stage, slightly complicated code will not be modified.

You can check whether the code can be modified. you only need to back up the code locally. You can also provide me with code files with the same functions without modifying them. 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 (! @ Mkdir ($ 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) {$ s1 = $ db-> fetch_array ("show create table '$ t'"); $ mysql = "/* Time :". date ("Y-m-d H: I: s "). "*/\ r \ nDROP table if exists '$ t'; \ r \ n ". $ s1 ['create Table']. "; \ r \ n"; $ a1 = $ db-> fetch_assoc ("select * from '$ t'"); foreach ($ a1 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 "data backup successful, backup file generation ". getcwd (). "/". $ filename. "/
The program automatically cleans up the backup five 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.