MSBI (SSIS/SSRS/SSAS) Online Training

Friday, January 30, 2009

ScriptFor Backup:-

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain
Public Sub Main()
Dim sSSASServerName As String = CStr(Dts.Variables(”SSASServerName”).Value)
Dim sBackupLocation As String = CStr(Dts.Variables(”BackupLocation”).Value)
If Right(sBackupLocation, 1) <> “\” Then sBackupLocation = sBackupLocation + “\”

Dim Locations() As Microsoft.AnalysisServices.BackupLocation
Dim oServer As New Microsoft.AnalysisServices.Server
oServer.Connect(sSSASServerName) ‘ connect to the server and start scanning down the object hierarchy
Dim oDB As Microsoft.AnalysisServices.Database
For Each oDB In oServer.Databases
‘If oDB.Name = “AdventureWords” Then ‘ here you can include or excluded databases
oDB.Backup(sBackupLocation & oDB.Name & “_” & Now().ToString(”yyyyMMdd_hhmmss”) & “.abf”, True, False, Locations, True)
‘End If
Dts.TaskResult = Dts.Results.Success
End Sub
End Class

No comments: