SQL Server job to delete old backups

  • JakDBA - Saturday, April 22, 2017 4:36 PM

    You can try using the power shell script... we are using the same.https://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09

    I'm still waiting for desire response.
    how to add check condition once full backup complete then run delete query other wise don't delete last backup.
    i'm having a proc but there is an issues can you rectify the same where it is problem

  • wasim.ahmad780 - Thursday, April 20, 2017 5:02 AM

    dwayne.bace - Tuesday, December 14, 2010 2:56 PM

    Hi river1The issue you are seeing is definately related to the flow control you have set up in the job.I suggest you open the job, and check the steps very carefully. Look at the order that the steps are listed in the job. They may not be listed in the order you create them....i.e. If you create a step (Delete Old Backups), then simply click 'new' to create a second job (Do Backups), the order will be: Step 1. Do Backups, Step 2.Delete Old Backups.You can change the order with the 'move step' buttons, If you still have problems, script the job and post it hereCheers

    Hi how to add check condition 
    unless db backup success then delete old backup if db backup failure of any reason then don't delete old backup

    You're using a maintenance plan, right?  Just use a Success constraint between the backup task and the cleanup task.  That means that the cleanup task will only be executed if the backup task succeeds.

    wasim.ahmad780 - Sunday, April 23, 2017 11:42 PM

    I'm still waiting for desire response.
    how to add check condition once full backup complete then run delete query other wise don't delete last backup.
    i'm having a proc but there is an issues can you rectify the same where it is problem

    I think the problem with your stored procedure is that you're attempting to use a function to assign a default value to two of the parameters.  Try assigning their value in the body of the stored procedure instead.

    John

  • river1 - Monday, December 13, 2010 4:57 AM

    Hi, I need to create a job that cleans backups and log backups that are older than a month.I do not want to create a maintenance plan, what i would like to create is a single job.Is it possible?How to do something like this?Tks, Pedro

    EXECUTE master.dbo.xp_delete_file 0, N'<Folder Location>',N'<extention>',N'<Older than date time>',1
    Sample
    EXECUTE master.dbo.xp_delete_file 0,N'C:\mybackups',N'bak',N'2017-08-01',1

Viewing 3 posts - 16 through 17 (of 17 total)

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