Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2008
    Posts
    21

    Unanswered: History Cleanup Task

    I have set up a history cleanup task to be performed once per week, however it doesn't seem to delete the old files, what am I doing wrong?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Old files......
    What files do you think it should be cleaning up?
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2008
    Posts
    21
    files older than 7 days, but they are still there

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    What is the file extension on the backups, and what version of SQL Server are you using?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Feb 2008
    Posts
    21
    SQL Server 2005
    .bak

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Do you have it set to inclued first-level subfolders?

    And are you seeing bak files left behind, or just the log files from the maintenance plan?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Feb 2008
    Posts
    21
    Here is the tsql for the cleanup task:

    declare @dt datetime select @dt = cast(N'2008-02-05T13:27:54' as datetime) exec msdb.dbo.sp_delete_backuphistory @dt
    GO
    EXEC msdb.dbo.sp_purge_jobhistory @oldest_date='2008-02-05T13:27:54'

    The History Cleanup task window shows backup and restore history, sql server agent job history and maintenance plan history checked and it says remove historical data older than 1 week. The connection is 'local server connection'.

    All BAK files are still there. All log files, such as error and some kind of backup related txt files, as well as the .trc files.

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    My clean-up task TSQL looks like this:
    EXECUTE master.dbo.xp_delete_file 0,N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup',N'bak',N'2008-01-22T16:16:54',1

    ...and my dialog box looks like this:
    Attached Thumbnails Attached Thumbnails CleanupTask.JPG  
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  9. #9
    Join Date
    Feb 2008
    Posts
    21
    I know what the issue is now. There is actually a History Cleanup and Maintenance Clean up. I was doing the History cleanup, but that one doesn't delete the .bak files the Maintenance Clean up does though.

    Thanks for your help!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •