PHP database backup file/volume-based import implementation

Source: Internet
Author: User

First, upload the backup files to the server one by one, pay attention to the evaluation of the volume label, and then perform the import operation.

// If you want to publish this article, please indicate the exit, no outgoing copyright notice, I do not like to see this kind of website. My work website does not indicate the person who is serving seven {see7di # gmail.com}

/*---------------------------------*/
Function _ doimport (){
$ F1 = _ r ($ _ Get ["f1"]);

// If it is the first loop
If ($ F1 = "1 "){
// Obtain the number of volumes first
For ($ I = 1; I I <1000; $ I ++ ){
If (file_exists ("./Cache/DB _". $ I. ". SQL ")){
Continue;
} Else {
$ _ Session ['_ num'] = ($ i-1 );
Break;
}
}
// Initialize the volume shard number
$ Fnum = 1;
} Else {
$ Fnum = _ r ($ _ Get ["fnum"]);
Settype ($ fnum, "integer ");
}

// Determine whether the process has ended
If ($ fnum> $ _ session ['_ num']) {
// Need to jump? Work = backdb delete user-uploaded backup files
Alert ("congratulations, all the backup files have been written to the database! \ N we recommend that you update the category cache and tag cache to ensure data correctness .","? Work = backdb ");
Die ();
}

$ Fp = file_get_contents ("./Cache/DB _". $ fnum. ". SQL ");
$ Fp = explode (';'. CHR (10), $ FP );
$ Fp = preg_replace ("/^ # (. *) \ n/is", "", $ FP );
// Echo "<textarea rows = '23' style = 'width: 100%; font-size: 12px; '> ";
Foreach ($ FP as $ key => $ Val ){
// Echo $ key. ":". trim ($ Val ). CHR (10 ). "====================================== ". CHR (10 );
Mysql_query (TRIM ($ Val ).";");
}
// Echo "</textarea> ";

Echo "<br> the system is restoring the database backup file dB _". $ fnum. ". SQL, please wait... <br> ";
Echo loading ($ fnum, $ _ session ['_ num']);
$ Fnum ++;
Alert ("","? Work = doimport & fnum = ". $ fnum ."");
}

The format of the SQL file to be imported depends on the format of volume-based export.

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.