Cleanup old backup files

  • Hello DBA folks,

    A database backup job is created using T-sql script (BACKUP DATABASE DB TO DISK = 'XXXX.BKP') and it creates one full backup everyday on local server. I would like to delete/clean up old database backp copies using T-SQL or DTS packages or SSIS packages. Any help is greatly appreciated. Maintenance plans shouldn't be used in my environment.

     

    Thanks,

    Bhushan

  • Since you are keeping a copy for everyday, I'm assuming the "XXXX" in your backup file name is MMDD, or something like that. If so, just determine which day(s) you want to delete, create a string representing the MMDD, build a string that does a delete on that file including the full path name, and use xp_cmdshell to make it disappear.

    If that's not it, we need more info, as I know you don't have multiple files in the same folder all with the same name.

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

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