一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

数据库备份系统

时间:2022-06-30 09:14:59 编辑:袖梨 来源:一聚教程网

数据库备份系统





数据库管理


数据库管理系统






<%
Dim ZC_DATABASE_PATH
'数据库的路径
ZC_DATABASE_PATH="database/data.mdb"
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 "" & showsize & ""
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
Engine.CompactDatabase "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
Engine.CompactDatabase "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////////////////////////
%>



热门栏目