Delete backups depending archive attribute

  • Hello all,

    firstly a small admission... I am one of these "accidental DBA's" that I read about, so I ask for your forgiveness straight away. 🙂 That said, if this topic has already been covered, and I have failed to find it, then I apologize in advance.

    To the point... is there a way, be it by maintenance plan or T-SQL etc, where by I can delete backup files (bak & trn), where the archive attribute on the files has been set to true, rather than what is currently in place, where the backup files are deleted once they are over two days old (maintenance plan).

    The reason I am asking this question is I recently discovered, that even thou the SQL server is doing it's job and carrying out the DB backups, the sysadmin for our third party backup system, has recently been playing with his backup routine, and consequently, there were changes made where there was an "accident" and a number of backups (bak & trn) did not make it to tape, prior to them reaching the two days old threshold and hosed out by the maintenance plan.

    If anyone can provide any help/advise, I would greatly appreciate it.

  • You can use the maintenance plans and add a cleanup task to remove backups. Note that this uses a location to delete, so if people are making backups in random places, this won't help.

    The general philosophy is that you don't want to delete a backup before a new one is made.

  • Hi Steve,

    thanks for the reply... I think the fact that I neglected to mention that the SQL server created backups (bak & trn) are going to HDD, may have confused the issues (ie. S:\ of the SQL server).

    It's only once Backup Exec copies the bak & trn files to tape, that I want SQL server to then do a clean up, deleting only the files where their archive attribute has been changed by Backup Exec (indicating they have been copied to tape)

    Sorry for the confusion.

Viewing 3 posts - 1 through 2 (of 2 total)

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