'************************************************************** ' backup a database log ' backup format of "sls" for SQL Lite Speed "bak" for SQL Backup ' fail if not one or the other ' same basic code as "Backup a Database" and "Differential ' Backup od a Database", just tweaked to di log backups '************************************************************** Option Explicit Function Main() Dim sBackupFolder, sSourceSQLServerName, sDatabaseName, sBackupFormat Dim oSourceSQLServer, oDB, oBackup Dim sFileName, sCommand sBackupFolder = DTSGlobalVariables("Backup Folder") sSourceSQLServerName = DTSGlobalVariables("Source SQL Server") sDatabaseName = DTSGlobalVariables("Database Name") sBackupFormat = DTSGlobalVariables("Backup Format") If NOT(LCase(sBackupFormat) = "bak") and NOT(LCase(sBackupFormat) = "sls") Then Err.Raise 1, "BackupDatabase", "Invalid Backup Format specified - must be sls (SQLLiteSpeed) or bak (native SQL backup)" End If If sDatabaseName <> "tempdb" Then Set oSourceSQLServer = CreateObject("SQLDMO.SQLServer2") oSourceSQLServer.LoginTimeout = 15 oSourceSQLServer.LoginSecure = True oSourceSQLServer.Connect sSourceSQLServerName ' make sure a good db name was provided Set oDB = oSourceSQLServer(sDatabaseName) ' set the backup disk device name If Right(sBackupFolder,1) <> "\" Then sBackupFolder = sBackupFolder & "\" End If sFileName = sBackupFolder & sDatabaseName & "." & sBackupFormat 'SQL Lite Speed Backup If sBackupFormat = "sls" Then ' backup the database sCommand = "EXEC master.dbo.xp_backup_log @database = '" & sDatabaseName & _ "', @filename = '" & sFileName & "', @init = 1" ' Q279514 explains why no ExecuteWithResultsAndMessages2 ' so don't capture QueryResult, just let it stream to stdout oSourceSQLServer.ExecuteWithResults(sCommand) End If 'SQL Server Backup If sBackupFormat = "bak" Then 'SQL backup Set oBackup = CreateObject("SQLDMO.Backup") oBackup.Database = oDB.Name oBackup.Files = sFileName oBackup.Initialize = True oBackup.SQLBackup oSourceSQLServer End If oSourceSQLServer.DisConnect Set oSourceSQLServer = Nothing End If ' valid db requested Main = DTSTaskExecResult_Success End Function