2

I have a maintenance plan setup for a databases on a server. As part of the backup is a Maintenance Cleanup Task.

SQL Version 2008

The task that 'succeeds' is setup as:

Delete backup files
Correct folder (same address as the backup task)
File extension: bak (NOT .bak)
Delete files older than: 20 Hour(s)

I have other similar cleanup tasks that occur in the same maintenance plan which work fine. This plan has worked fine in the past, I just noticed that last night it reported 'success' and the rest of the plan continued, however the file from 2 days ago still remains.

I have checked similar questions such as this question, and this is not the case as my maintenance task worked fine two days ago and for the past several weeks:

3 Answers 3

2

Check the file to see if it is a valid backup file. If the file is corrupt or in some other way damaged the process to remove the file won't do anything. You can check it by doing:

RESTORE HEADERONLY FROM DISK='d:\Path\To\Your\File.bak'
1
  • Thanks, this seems to have been the issue, the backup part of the plan was not ensuring the backups were valid.
    – Seph
    Mar 10, 2011 at 6:37
0

Another possible cause:

Check the owner of the backup files that don't get deleted.

I moved the backup location of the SQL server to a different disk, moving all existing backup files to the new location in the process.

Afterwards the files were owned by my administrative user and couldn't be deleted by the database service user.

To fix this easily:

  1. Open the properties of the backup root folder
  2. Go to the Security tab and click on Advanced
  3. Set the correct owner, in my case SQL Engine.
    enter image description here
    Make sure to enable the Replace owner on subcontainers and objects checkbox!
  4. Click on OK, wait for the process to finish and close all dialogs.

The maintenance plan should now be able again to delete the backup files.

0

I was experiencing the same issue. Providing sysadmin to the NT AUTHORITY\SYSTEM user allowed the query or job to action the deletes correctly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .