计算机故障网为您提电脑故障排除、电脑维修方法以及IT相关的各类资讯! 注册 - 登录 - 设为首页 - 加入收藏夹

php 备份数据库代码

来源:互联网 时间:2010-08-02 17:47 字体:[ ] 收藏 我要投稿 分享至微博

<?
//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);

顶一下
(1)
100%
踩一下
(0)
0%

责任编辑:计算机故障网

关于我们 - 联系我们 - 广告服务 - 版权声明 - 帮助 - 友情链接 - 网站地图 - RSS订阅 - baidu.xml

© CopyRight 2008-2010, WWW.JSJGZ.CN All Rights Reserved

计算机故障网 版权所有 专业电脑故障排除和电脑维修网站 闽ICP备09000710号