'********************************************************************** ' tape backup should have removed all except .bak or .sls from folder ' if any do exists the tape process may be off line, so do not overwrite ' just use the lowest number that does not exists in folder as the backup ' file extension ' either the .1 or the .bak/.sls could be in use by tape backup ' .bak/.sls could also be in use by a restore or another backup '************************************************************************ Option Explicit Function Main() Dim sBackupFolder, sDatabaseName, sBackupFormat Dim oFileSystem, sFileName, oFile Dim i sBackupFolder = DTSGlobalVariables("Backup Folder") sDatabaseName = DTSGlobalVariables("Database Name") sBackupFormat = DTSGlobalVariables("Backup Format") Set oFileSystem = CreateObject("Scripting.FileSystemObject") ' set the backup disk device name If Right(sBackupFolder, 1) <> "\" Then sBackupFolder = sBackupFolder & "\" End If sFileName = sBackupFolder & sDatabaseName & "." & sBackupFormat ' no sense trying to rename a file that doesn't exist If oFileSystem.FileExists(sFileName) Then ' find the next available numeric extension i = 1 While oFileSystem.FileExists(sBackupFolder & sDatabaseName & "." & CStr(i)) i = i + 1 Wend ' rename the .bak or .sls to the identified numeric extension If (oFileSystem.FileExists(sFileName)) Then Set oFile = oFileSystem.GetFile(sFileName) oFile.Name = sDatabaseName & "." & CStr(i) Set oFile = Nothing End If End If Main = DTSTaskExecResult_Success End Function