提示信息:<%
if request("action")="" then
response.write "不用我多说什么了吧!"
end if
';SQL Server 数据库的备份与恢复!
if request("action")="backupdatabase" Then
dim sqlserver,sqlname,sqlpassword,sqlLoginTimeout,databasename,bak_file,act
sqlserver = trim(request("sqlserver"))
sqlname = trim(request("sqlname"))
sqlpassword =trim(request("sqlpassword"))
sqlLoginTimeout = 15
databasename = trim(request("databasename"))
bak_file = trim(request("bak_file"))
bak_file = replace(bak_file,"$1",databasename)
act = lcase(request("act"))
if databasename = "" then
response.write "没有输入数据库名称!"
else
if act = "backup" then
Set srv=Server.createObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set bak = Server.createObject("SQLDMO.Backup")
bak.Database=databasename
bak.Devices=Files
bak.Action = 0
bak.Initialize = 1
';bak.Replace = True
bak.Files=bak_file
bak.SQLBackup srv
if err.number>0 then
response.write err.number&" " response.write err.description&"" end if Response.write "备份成功!" elseif act="restore" then ';恢复时要在没有使用数据库时进行! Set srv=Server.createObject("SQLDMO.SQLServer") srv.LoginTimeout = sqlLoginTimeout srv.Connect sqlserver,sqlname, sqlpassword Set rest=Server.createObject("SQLDMO.Restore") rest.Action=0 '; full db restore rest.Database=databasename rest.Devices=Files rest.Files=bak_file rest.ReplaceDatabase=True ';Force restore over existing database if err.number>0 then response.write err.number&" " response.write err.description&"" end if rest.SQLRestore srv Response.write "恢复成功!" else Response.write "请选择备份或恢复!" end if end if end if %> |
欢迎光临 黑色海岸线论坛 (http://bbs.thysea.com/) | Powered by Discuz! 7.2 |