Home >Backend Development >PHP Tutorial >PHP backup database code (1/10)_PHP tutorial
php backup database code This is a code for php mysql database backup and restore backup. You can back up the database of your website at will and restore it at the same time. This program generates a .sql database file. You can also import it with other tools. , convenient, all SQL database backup statements are generated, so the compatibility is good.
//php tutorial backup database tutorial code
This is a php mysql tutorial database backup and restoration code. You can back up the database of your website at will and restore it at the same time. This program generates a .sql database file. You can also use other tools. Importing is convenient and all SQL database backup statements are generated, so the compatibility is good.
*/
?>
import.php
/**
* Database backup program
*
* @author:黄乐
* @version:1.0
* @lastupdate:2010-7-19
*
*/include("config/config.php");
include("includes/dbbackup.class.php");
include("includes/msg.class.php");
$dbbackup = new dbbackup($dbhost, $dbuser, $dbpwd, $dbname);
$msg = new msg();
$bakfile = $dbbackup->get_backup(); //Get the backup file
if($_get['fn']){
if($dbbackup->import($_get['fn'])){ //Import data
$str = "Congratulations
The backup data has been successfully imported!"; //Prompt message
$msg->show_msg($str,'import.php','export.php'); //Prompt for successful import
}
}
//Delete backup file
if($_post['sub']){
echo $dbbackup->del($_post['choice'])? $msg->show_msg("Congratulations
The backup file has been successfully deleted!",'import.php','export.php' ): $msg->show_msg("Deletion failed!",'import.php','import.php');
}
?>
1 2 3 4 5 6 7 8 9 10