SQL Express 2008 Server Backup

16/10/2009 - 17:54 von Helmut Schneider | Report spam
Hi,

ich (als vbs-Laie) hab ein Backup Skript gebastelt (ich weiss, gibt es
schon, aber der Lerneffekt ist so grösser):

Const adOpenStatic = 3
Const adLockOptimistic = 3

server = "DBSERVER"
instances = Array("SQLEXPRESS", "SQLEXPRESS2", "SQLEXPRESS3")
backupRoot = "D:\Microsoft SQL Server\"
user = "domain\user"
pass = "password"

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

For Each instance In instances
backupDirectory = backupRoot & "MSSQL10." & instance & "\MSSQL\Backup\"
wscript.echo instance
objConnection.Open _
"Provider=SQLOLEDB;Data Source=" & server & "\" & instance & ";" & _
"Trusted_Connection=Yes;" & _
"User ID=" & user & ";Password=" & pass & ";"

objRecordSet.Open "SELECT name FROM sys.databases;", _
objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

For each database in objRecordSet.GetRows
wscript.echo database
If not (database = "tempdb") then
cmd="Backup Database " & database & " TO Disk='" & backupDirectory &
database & ".bak'"
objConnection.execute(cmd)
End If
next
objRecordSet.close
objConnection.close
next

wscript.echo "Done."

Das ganze funktioniert so lange, als dass die Datenbanken recht klein sind,
sind sie grösser (z.B. 2GB), kommt:

Query timeout expired.

Wie geht es richtig?

Danke und Gruß, Helmut

xpost, fup2 microsoft.public.de.german.scripting.wsh
 

Lesen sie die antworten

#1 Helmut Schneider
16/10/2009 - 18:11 | Warnen spam
Helmut 'Ingrid' Schneider wrote:
objConnection.Open _
"Provider=SQLOLEDB;Data Source=" & server & "\" & instance & ";" & _
"Trusted_Connection=Yes;" & _
"User ID=" & user & ";Password=" & pass & ";"




Nachtrag: Hab eben auch ConnectionTimeout versucht, fliege aber trotzdem
nach 30 Sekunden raus:

objConnection.ConnectionString = "Provider=SQLOLEDB;Data Source=" & server &
"\" & instance & ";" & _
"Trusted_Connection=Yes;" & _
"User ID=" & user & ";" & _
"Password=" & pass & ";"
objConnection.ConnectionTimeout = 600
objConnection.open

fup2 angepasst

Ähnliche fragen