Question : delete compressed bak files based on date in SQL server

I have a maintenance plan that will creates a backup of my db's to a network drive.  I then have a routine that compresses them in order to save space.  I want to use a maintenance plan to delete the zip files that are older than 7 days.  when I run the delete script , it says it runs but the files are not deleted.  I am backing up to a network drive using the ip address and folder name (i.e. \\10.0.0.5\backup) so I want to delete from the same directory.

any help would be greatly appreciated in solving this mystery.

Answer : delete compressed bak files based on date in SQL server

>> I then have a routine that compresses them in order to save space. I want to use a maintenance plan to delete the zip files that are older than 7 days.

Since the backup files are compressed, SQL Server doesn't recognizes those compressed backup files and hence not able to delete the zip files more than 7 days.

you have two options:

1. Remove the compression so that SQL Server recognizes them as valid backup files and delete it by checking whether it is older than 7 days.
2. Write a logic to delete files older than 7 days on your own and add it at the end of your Maintenance task or some other scheduled activity.

Hope this helps
Random Solutions  
 
programming4us programming4us