Deleting old backup files - maintenance cleanup task

  • Hi all,

    I have a maintenance plan with a "Maintenance Cleanup Task" pointing to a folder on a network drive.

    Unfortunately it is not working because I have it pointed to a folder that has several sub-folders which contain the backup (.bak) files. Do I have to create a task for each of the sub-folders or is there a work around I am missing or even a better method for this?

    The code is -

    EXECUTE master.dba.xp_delete_file 0,'\\serveretworkshare$\folder','bak','2010-05-10T12:00:00',1

  • If you are post SP2, there should be a checkbox to mark subfolders as existing for each database. Or are these not named for the databases?

  • Hi Steve,

    I am on MSSQL2005 SP2 and the only option I see similar to what you described for the Maintenance Cleanup Task is "Include first-level subfolders" but I would like to include second-level etc.

  • @chrisph

    I had the same problem few days back...

    When I created one mainteneance clean task and pointed to that folder contaning sub folders(wid .bak file) then, the job ran but no .bak file were deleted....

    So, I created many different maintenance clean task for each sub folder containing .bak file and then

    it deleted all the .bak files...

    I guess thats the longer way but it works fine...

    Sushant

    DBA

    Virgin Islands

    Regards
    Sushant Kumar
    MCTS,MCP

  • You cannot include second level folders. Only one level deep is how it works.

  • Thanks, I'll create individual tasks in that case.

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

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