php 备份数据库代码
<?
//php教程 备份数据库教程代码
这是一款php mysql教程数据库备份与还原备份的代码,你可以随便的对你网站的数据库进行备份,同时也可以还原哦,这程序生成的是.sql的数据库文件,你也可以用其它工具导入,方便,生成的都是sql数据库备份语句,所以兼容性好。
*/
?>
inport.php
<?php
/**
* 数据库备份程序
*
* @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(); //获取备份文件
if($_get['fn']){
if($dbbackup->import($_get['fn'])){ //导入数据
$str = "恭喜您<br>备份数据已经成功导入!"; //提示信息
$msg->show_msg($str,'import.php','export.php'); //提示导入成功
}
}
//删除备份文件
if($_post['sub']){
echo $dbbackup->del($_post['choice'])? $msg->show_msg("恭喜您<br>备份文件已删除成功!",'import.php','export.php') : $msg->show_msg("删除失败!",'import.php','import.php');
}
?><!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>powered by 黄乐</title>
<link href="css教程/dbbackup.css" rel="stylesheet" type="text/css" />
<script src="网页特效/jquery-1.4.2.min.js" type="text/网页特效"></script>
<script src="js/dbbackup.js" type="text/javascript"></script>
</head>
<body>
<form name="myform" method="post" action="">
<table><tbody>
<tr><td class="font-weight bg-blue">操作菜单</td></tr>
<tr><td>
<a href="export.php">备份数据</a>
<a href="import.php">还原数据</a>
</td></tr>
</tbody></table><table align="center"><tbody>
<tr><td style="font-weight:bold; background:#daedf5">提示信息</td></tr>
<tr><td class="prompt">
本功能在恢复备份数据的同时,将覆盖原有数据,请确定是否需要恢复,以免造成数据损失。<br /><br />
如果一个备份文件有多个分卷,您只需任选一个备份文件导入,程序会自动导入其他分卷
</td></tr>
</tbody></table><table id="content"><tbody>
<tr><td class="font-weight bg-blue" colspan="6">备份文件</td></tr>
<tr>
<td class="list font-green" width="5%" align="center">id</td>
<td class="list font-green" width="25%">文件名</td>
<td class="list font-green" width="15%" align="center">备份时间</td>
<td class="list font-green" width="15%" align="center">卷号</td>
<td class="list font-green" width="20%" align="center">导入</td>
<td class="list font-green" width="10%" align="center">删</td>
</tr>
<?php
$i = 1;
foreach($bakfile as $tb){
?>
<tr class="hover">
<td class="t list" width="5%" align="center"><?php echo $i; $i++; ?></td>
<td class="t list" width="25%"><?php echo $tb; ?></td>
<td class="t list" width="15%" align="center">
<?php
//取得备份时间
if(!preg_match("/_part/", $tb)){
$str = explode(".", $tb);
$time = substr($str[0],-10);
相关信息
- 2010-09-27 15:23:47PHP校验ISBN码的函数
- 2010-08-26 16:51:32PHP程序性能优化的53个要点
- 2010-08-24 23:12:26php生成随机密码的几种方法
- 2010-08-02 17:44:10ajax+php无刷新二级联动菜单的应用实例
- 2010-08-02 17:42:02php开发新手的成长之路——怎样成为开发高手
分享至微博