.RAR File's won't delete (Backups)

  • Through our maintenance plan, we have .rar files package our daily backups into a .rar each night. I'd like to delete all .rar files older than a week. This doesn't work when set in the maintenance plan. That isn't that surprising, however, when I script this:

    DECLARE @LastWeek [datetime]

    SET @LastWeek = DATEADD(d, +1, GETDATE())

    EXECUTE [master].[dbo].[xp_delete_file] 0,'I:\Backup','.rar',@LastWeek

    GO

    Still nothin! However, this process WILL delete anything else EXCEPT the .rar in that folder if I change '.rar.' to '*.*'. That process will delete all files except the .rar.

    Any ideas fellas?

  • What build are you running? Refer to -

    http://support.microsoft.com/kb/937137

    There are some fixes available in the post SP2 cumulative updates.

    You can use a script task in SSIS as a alternative - i.e use this in a ForEach Loop Container.

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Imports System.IO

    Public Class ScriptMain

    Public Sub Main()

    Try

    File.Delete(Dts.Variables("varFileDirectory").Value.ToString & "\" & Dts.Variables("varFileName").Value.ToString)

    Dts.Events.FireInformation(0, "", "File Deleted Succesfully", "", 0, True)

    Catch ex As Exception

    Dts.Events.FireError(0, "", "File Does Not Exist", "", 0)

    End Try

    'For Debugging Purposes

    'System.Windows.Forms.MessageBox.Show(Delete(Dts.Variables("varDirectory").Value.ToString & "\" & Dts.Variables("varFileName").Value.ToString))

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

  • Seen this before. Fire up Task Manager & check to see if there is still a rar.exe process running. If so, more than likely that is holding locks on the file(s).



    Scott Duncan

    MARCUS. Why dost thou laugh? It fits not with this hour.
    TITUS. Why, I have not another tear to shed;
    --Titus Andronicus, William Shakespeare


  • You may have errors on the file extension. See the link,

    http://www.sqlservercentral.com/Forums/Topic359308-338-1.aspx

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply