不过从6.0开始我就已经在用SQL版了,所以没怎么关心ACCESS版的数据备份问题,今天上动网找了找,还真有人写了,效果如何还不知道,试试看好了。
其大意是在论坛产生新一天重算的事件中,加入用于文件操作的代码,把指定的文件进行另存。方法如下:
1. 修改inc/dv_clsmain.asp。
找到Public Sub ReloadAllForumInfo(),在ReloadSetupCache TempStr,15之后加入:
程序代码:
‘备份数据库
call backupdaly()
call backupdaly()
2、在该文件的尾部加入:
程序代码:
Public sub backupdaly()
Dim Dbpath,Bkfolder,BkDbname,Fso
Dbpath="data/Dvbbs7.mdb"
Dbpath=server.mappath(Dbpath)
bkfolder="databackup"
bkfolder=server.mappath(bkfolder)
bkdbname="Backup"&year(now())&"_"&month(now())&"_"&day(now())&".mdb"
Set Fso=server.createobject("scripting.filesystemobject")
‘生成新的备份文件
if fso.fileexists(dbpath) then
fso.copyfile dbpath,bkfolder& "\"& bkdbname
End if
‘删除旧的备份文件
bkdbname="Backup"&year(now())&"_"&month(now())&"_"&day(now())-3&".mdb" ‘设定为保留3天的备份,根据自己的空间设定day后面减去的天数
if objFSO.fileExists(Server.MapPath(bkfolder& "\"& bkdbname)) then
objFSO.DeleteFile(Server.MapPath(bkfolder& "\"& bkdbname))
end if
End Sub
Dim Dbpath,Bkfolder,BkDbname,Fso
Dbpath="data/Dvbbs7.mdb"
Dbpath=server.mappath(Dbpath)
bkfolder="databackup"
bkfolder=server.mappath(bkfolder)
bkdbname="Backup"&year(now())&"_"&month(now())&"_"&day(now())&".mdb"
Set Fso=server.createobject("scripting.filesystemobject")
‘生成新的备份文件
if fso.fileexists(dbpath) then
fso.copyfile dbpath,bkfolder& "\"& bkdbname
End if
‘删除旧的备份文件
bkdbname="Backup"&year(now())&"_"&month(now())&"_"&day(now())-3&".mdb" ‘设定为保留3天的备份,根据自己的空间设定day后面减去的天数
if objFSO.fileExists(Server.MapPath(bkfolder& "\"& bkdbname)) then
objFSO.DeleteFile(Server.MapPath(bkfolder& "\"& bkdbname))
end if
End Sub
评论前必须登录!
注册