body,td,th{font-size:12px;}.STYLE1{color:#FFFFFF;font-weight:bold;}.STYLE2{color:#FF0000}-->" />

数据库备份与恢复

access,备份和恢复,完整,可用

<%
if session("username_tyadmin")="" then
response.redirect "index.asp"
response.end
end if
%>



<%
db="../xs_data/xs.mdb"
If Request.QueryString("action")="back" Then
currf=request.form("currf")
currf=server.mappath(currf)
backf=request.form("backf")
backf=server.mappath(backf)
backfy=request.form("backfy")
On error resume next
Set objfso = Server.CreateObject("Scripting.FileSystemObject")

if err then
err.clear
response.write ""
response.end
end if

if objfso.Folderexists(backf) = false then
Set fy=objfso.CreateFolder(backf)
end if

objfso.copyfile currf,backf& "\"& backfy
response.write ""
End If

If Request.QueryString("action")="ys" Then
currf=request.form("currf")
currf = server.mappath(currf)
ys=request.form("ys")
Const JET_3X = 4
strDBPath = left(currf,instrrev(currf,"\"))
on error resume next
Set objfso = Server.CreateObject("Scripting.FileSystemObject")
if err then
err.clear
response.write ""
response.end
end if

if objfso.fileexists(currf) then
Set Engine = CreateObject("JRO.JetEngine")
response.write strDBPath
on error resume next
If ys = "1" Then
https://www.360docs.net/doc/3217519848.html,pactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & currf, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "tourtemp.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
https://www.360docs.net/doc/3217519848.html,pactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & currf, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "tourtemp.mdb"
End If
objfso.CopyFile strDBPath & "tourtemp.mdb",currf
objfso.DeleteFile(strDBPath & "tourtemp.mdb")
Set objfso = nothing
Set Engine = nothing
if err then
err.clear
response.write ""
response.end
end if
response.write ""
response.end
Else
response.write ""
response.end
End If
end if

if Request.QueryString("action")="reload" then
currf=request.form("currf")
currf=server.mappath(currf)
backf=request.form("backf")
if backf="" then
response.write ""
else
backf=server.mappath(backf)
end if
on error resume next
Set objfso = Server.Crea

teObject("Scripting.FileSystemObject")
if err then
err.clear
response.write ""
response.end
end if
if objfso.fileexists(backf) then
objfso.copyfile ""&backf&"",""&currf&""
response.write ""
response.end
else
response.write ""
response.end
end if
end if
%>

















备份数据库
要求空间支持FSO
数据库路径:

备份数据目录:

数据库名称:



注:尽量不要更改以上项


















恢复数据库
要求空间支持FSO
当前数据库路径:

备份数据库路径:







============================================================================================================================




数据库管理



数据库管理系统







<%
Dim ZC_DATABASE_PATH
'数据库的路径
ZC_DATABASE_PATH="database/data.md

b"


data_array= Split(ZC_DATABASE_PATH,"/")


Dim action
action=trim(request("action"))
Dim dbpath,bkfolder,bkdbname,fso,fso1

Select Case action
Case ""
Call chushihua()
Case "CompressData" '压缩数据
Dim tmprs
dim allarticle
dim Maxid
dim topic,username,dateandtime,body
call CompressData()
case "BackupData" '备份数据
if request("act")="Backup" Then
call updata()
else
call BackupData()
end If
case "RestoreData" '恢复数据
dim backpath
if request("act")="Restore" Then
Dbpath=request.form("Dbpath")
backpath=request.form("backpath")
if dbpath="" Then
response.write "Please input your database whole Name"
else
Dbpath=server.mappath(Dbpath)
end If
backpath=server.mappath(backpath)

Set Fso=server.CreateObject("scripting.filesystemobject")
if fso.fileexists(dbpath) Then
fso.copyfile Dbpath,Backpath
response.write "数据库被成功还原!
"
else
response.write "没找到您所需要的数据库!"
end If
else
call RestoreData()
end If
Case "SpaceSize" '系统空间占用
call SpaceSize()
Case "deletebackup"
Dim dbname
dbpath=Request.QueryString("dbpath")
dbname=Request.QueryString("dbname")
dbpath=Server.MapPath(dbpath)
dbpath=dbpath &"\"&dbname
set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
fso.DeleteFile(DBPath)
Set fso = nothing
response.write "
您备份的数据库已经" & dbpath &"被成功删除!

返回.."
Else
response.write dbpath
response.write "
输入的路径错误,请确认后重新输入!

返回.."
End If
Case Else
End Select

%>


<%
response.write""

Sub chushihua()
%>




[压缩数据库]


[备份数据库]


[还原数据库]


[系统空间占用]





<%end sub%>

<%
'====================系统空间占用=======================
Sub SpaceSize()
On Error Resume Next
%>


系统空间查看






数据库:<%showSpaceinfo("../"&data_array(1)&"")%>


备份数据库:<%showSpaceinfo("databackup")%>


系统总共:<%showSpaceinfo("/")%>











返回...

<%
End Sub
%>
<% Sub ShowSpaceInfo(drvpath)
dim fso,d,size,showsize
set fso=server.CreateObject("scripting.filesystemobject")
drvpath=server.mappath(drvpath)
set d=fso.getfolder(drvpath)
size=d.size
showsize=size & " Byte"
if size>1024 Then
size=(Size/1024)
showsize=size & " KB"
end If
if size>1024 Then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end If
if size>1024 Then
size=(size/1024)
showsize=formatnumber(size,2) & " GB"
end If
response.write "" & sh

owsize & ""
End Sub
%>
<%
Sub RestoreData()
%>





还原数据库:




还原的路径(相对路径):


还原后的路径(相对路径):









返回...


<%
End Sub
Sub updata()
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 "
已经成功备份,你的数据库的路径:" &bkfolder& "\"& bkdbname
response.write "

点击此处将数据库下载下来:" & ZC_BLOG_HOST & request.form("bkfolder") & "/" & bkdbname &"

"
response.write "

当您下载完毕后,点击此处将删除备份的数据库!


返回..."
Else
response.write "Error ,,找不到文件!
"
End If
Set fso = nothing
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
Sub BackupData()
%>




备份数据库




当前数据库的路径(相对路径):


备份数据库的路径(相对路径):

如果该目录不存在,系统将自动建立


备份后数据库的名称: 按日期自动命名

如果备份文件不存在将建立,如果存在,将自动覆盖!









返回..

<%
End Sub
Sub CompressData()
%>

压缩数据库:





输入数据库的所在路径




压缩数据库的路径:






如果是ac97,请将钩打上.(默认是Access 2000)






返回..

<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")

If dbpath <> "" Then
dbpath = server.mappath(dbpath)
response.write(CompactDB(dbpath,boolIs97))
End If

End Sub

'=====================压缩参数=========================
Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath,JET_3X
strDBPath = Left(dbPath,InStrRev(DBPath,"\"))
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(dbPath) Then
fso.CopyFile dbpath,strDBPath & "temp.mdb"
Set Engine = CreateObject("JRO.JetEngine")

If boolIs97 = "True" Then
https://www.360docs.net/doc/3217519848.html,pactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
https://www.360docs.net/doc/3217519848.html,pactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"
End If

fso.CopyFile strDBPath & "temp1.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
fso.DeleteFile(strDBPath & "temp1.mdb")
Set fso = nothing
Set Engine = nothing

CompactDB = "您的数据库" & dbpath & "已经被成功压缩!" & vbCrLf

Else
CompactDB = "
您输入的路径错误,请确认后重新输入!" & vbCrLf
End If

End Function


'////////////////////end////////////////////////
%>








相关主题
相关文档
最新文档