asp 온라인 백업 및 sqlserver 데이터베이스 복구 코드

asp 온라인 백업 sql 서버 데이터베이스:1,백업 sqlserver
 
<%
SQL="backup database to disk='"&Server.MapPath("backup")&"\"&"backuptext.dat"&"'"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server= ;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err<>0 then
response.wrITe " :"&err.Descripting
else
response.wrITe " !"
end if
%>
2,복구 sqlserver
 
<%
SQL="Restore database from disk='"&Server.MapPath("backup")&"\"&"backuptext.dat"&"'"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server= ;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err<>0 then
response.wrITe " :"&err.Descripting
else
response.wrITe " !"
end if
%>
ACCESS 원리 와 마찬가지 로
 
<%
'*****************************************
function CopyTo(ByVal cFile,ByVal toFile)
cFile=Server.MapPath(cFile) ‘
toFile=Server.MapPath(toFile) ‘
Dim cFso,cf
set cFso=Server.CreateObject("Scripting.FileSystemObject")
cFso.fileexists(cFile)
cFso.Copyfile cFile,toFile
end function
'*********************************************
' ASP ACCESS
' databackup.asp
dim dbpath,bkfolder,bkdbname,fso,fso1
call main()
call main2()
conn.close
set conn=nothing
sub main()
if request("action")="Backup" then
call backupdata()
else
%>
<table cellspacing=1 cellpadding=1 align=center width="90%">
<tr>
<th height=25 >
&nbsp;&nbsp;<B> </B>
</th>
</tr>
<form method="post" action="databackup.asp?action=Backup">
<tr>
<td height=100 style="line-height:150%">
&nbsp;&nbsp;
( ):
<input type=text size=15 name=DBpath value="../mdb/database.mdb"><BR>
&nbsp;&nbsp; ( ):
<input type=text size=15 name=bkfolder value=../Databackup>&nbsp; , <BR>
&nbsp;&nbsp; ( ):
<input type=text size=15 name=bkDBname value=database.mdb> &nbsp;

, , , <BR>
&nbsp;&nbsp;<input type=submIT value=" "><hr align="center" width="90%" color="#999999"></td>
</tr>
</form>
</table>
<%
end if
end sub
sub main2()
if request("action")="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)
Response.wrITe Backpath
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
fso.copyfile Dbpath,Backpath
response.wrITe "<font color=red> !</font>"
else
response.wrITe "<font color=red> !</font>"
end if
else
%>
<table align=center cellspacing=1 cellpadding=1 width="90%">
<tr>
<th height=25 >
&nbsp;&nbsp;<B> </B>
</th>
</tr>
<form method="post" action="databackup.asp?action=Restore">
<tr>
<td height=100 >
&nbsp;&nbsp; ( ):
<input type=text size=30 name=DBpath value="../Databackup/database.mdb">&nbsp;&nbsp;<BR>
&nbsp;&nbsp; ( ):
<input type=text size=30 name=backpath value="../mdb/database.mdb"><BR>
&nbsp;&nbsp;<input type=submIT value=" "> <hr width="90%" align="center" color="#999999">
&nbsp;&nbsp;<font color="#666666">・ : &nbsp;&nbsp;</font></td>
</tr>
</form>
</table>
<%
end if
end sub
sub backupdata()
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 "<font color=red> , " &bkfolder& "\\"& bkdbname+"</font>"
Else
response.wrITe "<font color=red> 。</font>"
End if
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
%>

좋은 웹페이지 즐겨찾기