Cleanup Backup in SQL 2005

  • Hi all,

     

    I am trying to have Maintenance plan to work for me to clean or delete Backup which is two days old but the clean up history part of plan doesn't work at all it does cleans history of job, and other thing but not deleting the file of backup(test.bak)

    is there other way to work on that?

    Please let meknow

    Thanks

  • You can use a Maint. Clean up task. It will delete backup files older than N days etc etc.

    Thanks

    Rich

  • If cleanup task won't work you can use the procedure...

    declare @dt datetime

    set @dt = getdate()-2

    EXECUTE master.dbo.xp_delete_file 0,N'\\sql2k5\SQLBackup\,N'.bak', @dt

    MohammedU
    Microsoft SQL Server MVP

  • I think it will delete the old backup files only if you have not created them in separate sub directories.  This a know bug.

    ron

  • If you use the Maintenance Cleanup Task inside the subplan it wil work all fine.

    NOTE you must use the workflow inside the step (on completion/success/failure arrows) other wise the next task will not be performed.

    Inside the Maintenance Cleanup Task is't possible to select the option "Include first-level subfolders" , this in case you use the option "Create a sub-directory for each database".

    This last option is only available when you installed the latest SP for SQL 2005.

    It works fine with our organisation.

  • Thanks to Mohammed for posting this simple 3 line script. This is what I was looking for and it is working for what I a specific situation.

    Jennifer

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

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