以下的代码是从PJBLOG中剥离出来的网站数据库备份、压缩修复、恢复,以及附件的浏览、删除的管理程序,只要修改一下路径和自己网站的配置就可已使用在自己的系统中:
程序代码
<%if Request.QueryString("Fmenu")="SQLFile" then '数据库与文件%>
<%=categoryTitle%> |
---|
<%getMsg%>
<% if Request.QueryString("Smenu")="Attachments" then %> <%else%> "
Response.Write "压缩数据库开始,网站暂停一切用户的前台操作… " Response.Write "关闭数据库操作… " call CloseDB Application.Lock FreeApplicationMemory Application(CookieName & "_SiteEnable") = 0 Application(CookieName & "_SiteDisbleWhy") = "网站暂停中,请稍候几分钟后再来…" Application.UnLock Set AccessEngine = CreateObject("JRO.JetEngine") AccessEngine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(AccessFile), "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(AccessFile & ".temp") AccessFSO.CopyFile Server.Mappath(AccessFile & ".temp"),Server.Mappath(AccessFile) AccessFSO.DeleteFile(Server.Mappath(AccessFile & ".temp")) Set AccessFSO = Nothing Set AccessEngine = Nothing Application.Lock Application(CookieName & "_SiteEnable") = 1 Application(CookieName & "_SiteDisbleWhy") = "" Application.UnLock Response.write "压缩数据库完成… " Application.Lock Application(CookieName & "_SiteEnable") = 1 Application(CookieName & "_SiteDisbleWhy") = "" Application.UnLock Response.Write "网站恢复正常访问…" Response.Write " " "
Response.Write "备份数据库开始,网站暂停一切用户的前台操作… " Response.Write "关闭数据库操作… " call CloseDB Application.Lock FreeApplicationMemory Application(CookieName & "_SiteEnable") = 0 Application(CookieName & "_SiteDisbleWhy") = "网站暂停中,请稍候几分钟后再来…" Application.UnLock CopyFiles Server.Mappath(AccessFile),Server.Mappath("backup/Backup_" & DateToStr(Now(),"YmdHIS") & "_" & randomStr(8) &".mbk") Application.Lock Application(CookieName & "_SiteEnable") = 1 Application(CookieName & "_SiteDisbleWhy") = "" Application.UnLock Response.write "压缩数据库完成… " Application.Lock Application(CookieName & "_SiteEnable") = 1 Application(CookieName & "_SiteDisbleWhy") = "" Application.UnLock Response.Write "网站恢复正常访问…" Response.Write " " "
Response.Write "还原数据库开始,网站暂停一切用户的前台操作… " Response.Write "关闭数据库操作… " call CloseDB Application.Lock FreeApplicationMemory Application(CookieName & "_SiteEnable") = 0 Application(CookieName & "_SiteDisbleWhy") = "网站暂停中,请稍候几分钟后再来…" Application.UnLock CopyFiles Server.Mappath(AccessFile),Server.Mappath(AccessFile & ".TEMP") if DeleteFiles(Server.Mappath(AccessFile)) then response.write ("原数据库删除成功 ") response.write CopyFiles(Server.Mappath(AccessSource),Server.Mappath(AccessFile)) if DeleteFiles(Server.MapPath(AccessSource)) then response.write ("数据库备份删除成功 ") if DeleteFiles(Server.Mappath(AccessFile & ".TEMP")) then response.write ("Temp备份删除成功 ") Application.Lock Application(CookieName & "_SiteEnable") = 1 Application(CookieName & "_SiteDisbleWhy") = "" Application.UnLock Response.write "数据库还原完成… " Application.Lock Application(CookieName & "_SiteEnable") = 1 Application(CookieName & "_SiteDisbleWhy") = "" Application.UnLock Response.Write "网站恢复正常访问…" Response.Write " " "
if DeleteFiles(Server.MapPath(AccessSource)) then response.write ("数据库备份删除成功 ") Response.Write " " |
评论前必须登录!
注册