public function recovery()
 {
     set_time_limit(300);
     $DataDir = "./Data/database/";
     import("@.ORG.MySQLReback");
     $config = array('host' => C('DB_HOST'), 'port' => C('DB_PORT'), 'userName' => C('DB_USER'), 'userPassword' => C('DB_PWD'), 'dbprefix' => C('DB_PREFIX'), 'charset' => 'utf8', 'path' => $DataDir, 'isCompress' => 1, 'isDownload' => 0);
     $mr = new MySQLReback($config);
     $mr->setDBName(C('DB_NAME'));
     $filename = strtotime($_GET['time']) . ".sql";
     $mr->recover($filename);
     $this->success("成功恢复数据库!");
 }
Beispiel #2
0
<?php

include "../common.inc.php";
ini_set('memory_limit', '50M');
include "function_common.php";
require_once 'mysqlbak.class.php';
InitGP(array('action', 'dbdir', 'gzip'));
//初始化变量全局返回
//$db->link;
$backupDir = 'data';
$gzip = $gzip ? 1 : 0;
$config = array('host' => $dbhost, 'port' => 3306, 'userName' => $dbuser, 'userPassword' => $dbpw, 'charset' => $dbcharset, 'path' => './' . $backupDir . '/', 'isCompress' => $gzip, 'isDownload' => 0);
$mr = new MySQLReback($config);
$mr->setDBName($dbname);
//$mr->recover('backup@artas_test@20090707080609.sql.gz');
if ($action == "backup") {
    $mr->backup();
    showmsg("备份数据库成功!", "dbbak.php");
} elseif ($action == "restore" and !empty($dbdir)) {
    $mr->recover($dbdir);
    showmsg("恢复数据库成功!", "dbbak.php");
} elseif ($action == "del" and !empty($dbdir)) {
    $filepath = './' . $backupDir . '/' . $dbdir;
    @unlink($filepath);
    showmsg("删除数据库备份成功!", "dbbak.php");
} elseif ($action == "down" and !empty($dbdir)) {
    $filepath = './' . $backupDir . '/' . $dbdir;
    $mr->downloadFile($filepath);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">