I have used this script on multiple SQL servers, 2000 and 2005. I have a SQL 2000 server (w2k3 R2 SP2) which I have been unable to get any sort of automated backup working for months. I have to right-click each DB (about 20 of them) and choose ALL TASKS --> BACKUP DATABASE just to back them up.
Every time I set aside time to work on it, I encounter the same thing as before and not really sure where to start. Event viewer gives me nothing but I do get a WSH error...
Here is the script with the server name and password replaced with SERVER and PASSWORD:
--------------------------------------------------------
Dim Server(0)
Server(0) = "DRIVER={SQL Server};Server=SERVER;Database=master;uid=SQLBackup;pwd=PASSWORD"
Dim BackupLocation(0)
BackupLocation(0) = "F:\Baks"
Dim Exclusions(0)
Exclusions(0) = ""
For t = 0 to UBOUND(Server)
set Connection = CreateObject("ADODB.Connection")
Connection.Open Server(t)
set rs = CreateObject("ADODB.Recordset")
rs.Open "select name, status from sysdatabases where UPPER(name) not in ('master', 'model', 'msdb', 'tempdb')", Connection, 3, 2, 1
Do
myExclusions = Split(Exclusions(t), ",")
FoundExclusion = False
For x = 0 to UBOUND(myExclusions)
If UCASE(myExclusions(x)) = UCASE(rs.fields("name")) Then FoundExclusion = true
Next
If FoundExclusion = False Then Connection.Execute "BACKUP DATABASE [" & rs.fields("name") & "] TO DISK = N'" & BackupLocation(t) & rs.fields("name") & ".bak' WITH INIT , NOUNLOAD , NAME = N'" & rs.fields("name") & " backup', NOSKIP , STATS = 10, NOFORMAT"
rs.movenext
Loop Until rs.EOF
rs.Close
Connection.Close
Next
--------------------------------------------------------
Every time I set aside time to work on it, I encounter the same thing as before and not really sure where to start. Event viewer gives me nothing but I do get a WSH error...
Here is the script with the server name and password replaced with SERVER and PASSWORD:
--------------------------------------------------------
Dim Server(0)
Server(0) = "DRIVER={SQL Server};Server=SERVER;Database=master;uid=SQLBackup;pwd=PASSWORD"
Dim BackupLocation(0)
BackupLocation(0) = "F:\Baks"
Dim Exclusions(0)
Exclusions(0) = ""
For t = 0 to UBOUND(Server)
set Connection = CreateObject("ADODB.Connection")
Connection.Open Server(t)
set rs = CreateObject("ADODB.Recordset")
rs.Open "select name, status from sysdatabases where UPPER(name) not in ('master', 'model', 'msdb', 'tempdb')", Connection, 3, 2, 1
Do
myExclusions = Split(Exclusions(t), ",")
FoundExclusion = False
For x = 0 to UBOUND(myExclusions)
If UCASE(myExclusions(x)) = UCASE(rs.fields("name")) Then FoundExclusion = true
Next
If FoundExclusion = False Then Connection.Execute "BACKUP DATABASE [" & rs.fields("name") & "] TO DISK = N'" & BackupLocation(t) & rs.fields("name") & ".bak' WITH INIT , NOUNLOAD , NAME = N'" & rs.fields("name") & " backup', NOSKIP , STATS = 10, NOFORMAT"
rs.movenext
Loop Until rs.EOF
rs.Close
Connection.Close
Next
--------------------------------------------------------