What to do to clean transaction logs in back up directory

  • we have in our Maintenance plan to remove trn files older day1 but logs are not clearing in backup directoy.what to do tofix this problem.

    Thanks in advance

     

  • Hello,

    Please create a job with a Job Step that is of Type ActiveX script and Language VBscript. Then enter a script that uses FileSystemObject See the example of the script at

    http://www.enterpriseitplanet.com/resources/scripts_win/article.php/3081721

    It is exactly your task, it says:

    '

    ' Script to delete files older than a given number of days.

    '

    Do not forget to specify your number of days. Or better ask your friend the developer to check the script out.

    We are using similar job step and our own script to delete old files in the backup directory. You may modify their script to include checking for file extension or file size something like that (this is just part of the script...):

       

        For each MyFile In objFolder.Files

            If UCase(Right(MyFile.name,4)) = ".LOG" then

             If ABS(DateDiff("n", now , MyFile.DateCreated)) > PredefinedMinutes then

              If MyFile.Size > fileMinSize then

    '    Do Your Processing Here......               

                     Exit For

              End If

             End If

            End If

        Next

       

    Regards,Yelena Varsha

  • Are they really old logs? Maybe SQL Server doesnt even know they exist. The Maintenance Plans dont look at the disk to see what files are there, they use the msdb.sysbackupmedia table.

    Does SQL Server (and SQL Server Agent) have permission to delete the files?

    Maybe just delete everything out of the directory and then see how the maintenance plans go after a few days.


    Julian Kuiters
    juliankuiters.id.au

  • Check that your maintenance plan is not including databases that have simple recovery model.  Tlog backup step occurs before tlog cleanup step, so tlog backup step will fail for simple recovery db's which prevents the tlog cleanup step from running.  

    Jeff 

  • If the current log files are not getting deleted, try re-creating the maintenance plan.

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

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