⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_db_backup.asp

📁 一个网络相册
💻 ASP
字号:
<link href="Admin_Style.css" rel="stylesheet" type="text/css">
<%
  if session("purview")<>"99999" then
      response.redirect "../login.asp?id=0"
	  response.end
  end if
  
dim action
dim admin_flag

Function finddir(filepath)
	finddir=""
	for i=1 to len(filepath)
	if left(right(filepath,i),1)="/" or left(right(filepath,i),1)="\" then
	  abc=i
	  exit for
	end if
	next
	if abc <> 1 then
	finddir=left(filepath,len(filepath)-abc+1)
	end if
end Function


	action=trim(request("action"))

dim dbpath,bkfolder,bkdbname,fso,fso1
Dim uploadpath

	'备份数据

select case action
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 "请输入您要恢复成的数据库全名"	
			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 "<br>"
			response.write "<br>"
			response.write "<br>"
			response.write "<center>成功恢复数据!"
			response.write "</center>"			
			else
			response.write "备份目录下并无您的备份文件!"	
			end if
		else
		
			call RestoreData()
		end if
end select


'====================备份数据库=========================
sub BackupData()
If IsSqlDataBase = 1 Then
	SQLUserReadme()
	Exit Sub
End If
%>
	<div align="center">
	<table border="0"  cellspacing="1" cellpadding="5" height="1" width="80%" class="tableBorder">
  				<tr>
  					<th height=20 >
  					&nbsp;&nbsp;<B>备份数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )
  					</th>
  				</tr>
  				<form method="post" action="admin_db_backup.asp?action=BackupData&act=Backup">
  				<tr>
  					<td height=20 class="forumrow">
  						 </td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;当前数据库路径(相对路径):<input type=text size=45 name=DBpath value="../album.asa"></td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;备份数据库目录(相对路径):<input type=text size=45 name=bkfolder value=..\Databackup>&nbsp;<br>
&nbsp;<font color="#FF0000">如目录不存在,程序将自动创建</font></td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;备份数据库名称(填写名称):<input type=text size=45 name=bkDBname value=#album.mdb>&nbsp;<br>
&nbsp;<font color="#FF0000">如备份目录有该文件,将覆盖,如没有,将自动创建</font></td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						<p align="center">
						<input type=submit value="备份数据" style="border: 1px solid #FFFFFF"></td>
  				</tr>	
  				<tr>
  					<td class="forumrow">
  						 </td>
  				</tr>	
  				</form>
  			</table>
</div>
<%
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 "<br>"
			response.write "<br>"
			response.write "<br>"						
			response.write "<center>备份数据库成功,您备份的数据库路径为 服务器空间的:" &bkfolder& "\"& bkdbname
			response.write "</center>"
		Else
			response.write "找不到您所需要备份的文件。"
		End if
end sub
'====================恢复数据库=========================
sub RestoreData()

%>
<div align="center">
<table border="0"  cellspacing="1" cellpadding="5" height="160" width="80%" class="tableBorder">
	<th height=20 >
   					&nbsp;&nbsp;<B>恢复数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )
  					</th>
  				</tr>
				<form method="post" action="admin_db_backup.asp?action=RestoreData&act=Restore">
  				
  				<tr>
  					<td height=20 class="forumrow">
  						 </td>
  				</tr>	
  				
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;备份数据库路径(相对):<input type=text size=30 name=DBpath value="..\DataBackup\#album.mdb">&nbsp;</td>
  				</tr>	
  				
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;目标数据库路径(相对):<input type=text size=30 name=backpath value="..\album.asa"></td>
  				</tr>		
  				<tr>
  					<td class="forumrow">
  						<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit value="恢复数据" style="border: 1px solid #FFFFFF">
  					</td>
  				</tr>	
  				</form>
  			</table>
</div>

<%
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
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -