<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if session("AdminName") = "" then
    response.Redirect "Admin_Login.asp"
end if
%>
<!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" />



<link href="Common/Style.css" rel="stylesheet" type="text/css">

</head>
<body>

<div id="All">
<div id="ShowMain">
  <div class="TitleBar">通过丰富的配置,您可以建立一个属于您自己的播客家园.</div>
  <div id="TabContent">
    <div class="ShowSimpleCon">


<form method="post" name="myform" action="?action=backupdatabase">
<table width="100%" border="1" align="center">
  <tr>
    <td width="100%" height="30" align="center" bgcolor="#330066"><font color="#FFFFFF">备份MSSQL数据</font></td>
  </tr>
  <tr>
    <td>选择操作：
      <input type="radio" name="act" id="act_backup"value="backup" />
      <label for=act_backup>备份</label>
      <input type="radio" name="act" id="act_restore" value="restore" />
      <label for=act_restore>恢复</label></td>
  </tr>
  <tr>
    <td><label>SQL服务器:
        <input type="text" name="sqlserver" value="localhost" />
    </label></td>
  </tr>
  <tr>
    <td><label>用 户 名  :
        <input name="sqlname" type="text" value="sa" />
    密&nbsp; 码:
    <input type="text" name="sqlpassword" />
</label></td>
  </tr>
  <tr>
    <td><label>数据库名：
        <input type="text" name="databasename" value="<%=request("databasename")%>" />
    </label></td>
  </tr>
  <tr>
    <td>文件路径：
      <input name="bak_file" type="text" value="<% =server.MapPath("\")&"\"&"liuyes.bak"%>" size="60" />
(备份或恢复的文件路径)</td>
  </tr>
  <tr>
    <td><% Response.write "本文件绝对路径:" %>
      <font color="#FF0000">
      <% =server.mappath(Request.ServerVariables("SCRIPT_NAME")) %>
      </font></td>
  </tr>
  <tr>
    <td><input name=submit1 type="submit" class="liuyes" id=submit1 size="10" value="确  定" />
      &nbsp;&nbsp; <input name="Submit" type="reset" class="liuyes" size="10" value="重  置" /></td>
  </tr>
</table>
</form> 
<table width="100%" border="1" align="center">
  <tr>
    <td>提示信息:<% 
if request("action")="" then	
  response.write "<font color=#ff0000>不用我多说什么了吧！</font>"
end if
'SQL Server 数据库的备份与恢复! 
if request("action")="backupdatabase" Then 
dim sqlserver,sqlname,sqlpassword,sqlLoginTimeout,databasename,bak_file,act 
sqlserver = trim(request("sqlserver"))
sqlname = trim(request("sqlname"))
sqlpassword =trim(request("sqlpassword"))
sqlLoginTimeout = 15
databasename = trim(request("databasename")) 
bak_file = trim(request("bak_file")) 
bak_file = replace(bak_file,"$1",databasename)
act = lcase(request("act"))
if databasename = "" then
response.write "<font color=#ff0000>没有输入数据库名称!</font>"
else
if act = "backup" then
Set srv=Server.CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set bak = Server.CreateObject("SQLDMO.Backup")
bak.Database=databasename
bak.Devices=Files 
bak.Action   = 0
bak.Initialize   = 1
'bak.Replace        = True
bak.Files=bak_file 
bak.SQLBackup srv
if err.number>0 then 
response.write err.number&"<font color=red><br>" 
response.write err.description&"</font>" 
end if
Response.write "<font color=green>备份成功!</font>" 
elseif act="restore" then
'恢复时要在没有使用数据库时进行！ 
Set srv=Server.CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set rest=Server.CreateObject("SQLDMO.Restore")
rest.Action=0 ' full db restore 
rest.Database=databasename 
rest.Devices=Files 
rest.Files=bak_file 
rest.ReplaceDatabase=True 'Force restore over existing database 
if err.number>0 then
response.write err.number&"<font color=red><br>"
response.write err.description&"</font>"
end if
rest.SQLRestore srv
Response.write "<font color=green>恢复成功!</font>"
else 
Response.write "<font color=red>请选择备份或恢复!</font>"
end if 
end if 
end if
%></td>
  </tr>
</table> 
</body>
</html>
    </div>
    <div style="clear:both"></div>
  </div>
</div>

<div class="FooterDiv">
  <p class="Text"><span>Copyright &copy; 2006-2007 <a href="Http://Www.WuhU263.Cn/" target="_blank">芜湖播客家园</a> 版权所有. 并保留一切权利.</p>

</div>
</div>
</body>
</html>