📄 admin_data_backup.asp
字号:
<!--#include file="checkuser.asp"-->
<%
if oskey<>"supper" then
response.Write "<script language=javascript>alert('您无权访问!');window.close();</script>"
response.end
end if
%>
<html>
<head>
<title>∷企业生产管理信息系统:.</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/main.css" rel="stylesheet" type="text/css">
<SCRIPT language=javascript src="css/init.js">
</SCRIPT>
<style type="text/css">
<!--
td { font-family: "宋体"; font-size: 9pt}
body { font-family: "宋体"; font-size: 9pt}
select { font-family: "宋体"; font-size: 9pt}
A {text-decoration: none; color: #336699; font-family: "宋体"; font-size: 9pt}
A:hover {text-decoration: underline; color: #FF0000; font-family: "宋体"; font-size: 9pt}
-->
</style>
<!--#include file="conn.asp"-->
</HEAD>
<BODY topMargin=0 rightMargin=0 leftMargin=0>
<!--#include file="top.asp"-->
<%
'*****************************************
function CopyTo(ByVal cFile,ByVal toFile)
cFile=Server.MapPath(cFile) '所要备份的文件
toFile=Server.MapPath(toFile) '备份文件
Dim cFso,cf
set cFso=Server.CreateObject("Scripting.FileSystemObject")
cFso.fileexists(cFile)
cFso.Copyfile cFile,toFile
end function
'*********************************************
'ASP实现备份及恢复ACCESS数据库操作
'本页面为 databackup.asp
call main()
call main2()
sub main()
if request("action")="Backup" then
call backupdata()
else
%>
<br><br><br>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><hr align="center" width="100%" color="#999999" /></td>
</tr>
</table>
<table cellspacing=1 cellpadding=1 align=center width="80%">
<tr>
<th height=25 >
<B>数据库备份</B>
</th>
</tr>
<form method="post" action="Admin_Data_Backup.asp?action=Backup">
<tr>
<td height=100 style="line-height:150%">
当前数据库路径(相对路径):
<input type=text size=15 name=DBpath value="data/data.mdb">
<BR>
备份数据库目录(相对路径):
<input type=text size=15 name=bkfolder value=Databackup> 如目录不存在,程序将自动创建<BR>
备份数据库名称(填写名称):
<input type=text size=15 name=bkDBname value=www#db.mdb>
如备份目录有该文件,将覆盖,如没有,将自动创建<BR>
<input type=submit value="备份数据"><hr align="center" width="100%" color="#999999"></td>
</tr>
</form>
</table>
<%
end if
end sub
sub main2()
if request("action")="Restore" then
Dbpath=request.form("Dbpath")
backpath=request.form("backpath")
if dbpath="" then
response.write "请输入您要恢复成的数据库全名"
else
Dbpath=server.mappath(Dbpath)
end if
backpath=server.mappath(backpath)
Response.write Backpath
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
fso.copyfile Dbpath,Backpath
response.write "<font color=red>成功恢复数据!</font>"
else
response.write "<font color=red>备份目录下并无您的备份文件!</font>"
end if
else
%>
<br><table align=center cellspacing=1 cellpadding=1 width="80%">
<tr>
<th height=25 >
<B>恢复数据库</B>
</th>
</tr>
<form method="post" action="Admin_Data_Backup.asp?action=Restore">
<tr>
<td height=100 >
备份数据库路径(相对):
<input type=text size=30 name=DBpath value="Databackup/www#db.mdb">
<BR>
当前数据库路径(相对):
<input type=text size=30 name=backpath value="data/data.mdb">
<BR>
<input type=submit value="恢复数据"> <hr width="100%" align="center" color="#999999">
<font color="#666666">·注意:所有路径都是相对路径 </font></td>
</tr>
</form>
</table>
<%
end if
end sub
sub backupdata()
Dbpath=request.form("Dbpath")
Dbpath=server.mappath(Dbpath)
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
If CheckDir(bkfolder) = True Then
fso.copyfile dbpath,bkfolder& "\\"& bkdbname
else
MakeNewsDir bkfolder
fso.copyfile dbpath,bkfolder& "\\"& bkdbname
end if
response.write "<font color=red>备份数据库成功,您备份的数据库路径为" &bkfolder& "\\"& bkdbname+"</font>"
Else
response.write "<font color=red>找不到您所需要备份的文件。</font>"
End if
end sub
'------------------检查某一目录是否存在-------------------
Function CheckDir(FolderPath)
folderpath=Server.MapPath(".")&"\\"&folderpath
Set fso1 = CreateObject("Scripting.FileSystemObject")
If fso1.FolderExists(FolderPath) then
'存在
CheckDir = True
Else
'不存在
CheckDir = False
End if
Set fso1 = nothing
End Function
'-------------根据指定名称生成目录---------
Function MakeNewsDir(foldername)
dim f
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
%>
<br>
<!--#include file="footer.htm"--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -