Link to home
Start Free TrialLog in
Avatar of AIC-Admin
AIC-AdminFlag for United States of America

asked on

SQL 2005 DB Backup Doesn't Remove Old Backup Copies

I used SQL Server Management Studio Maintenace Plan wizard to create a backup job that backs up a database nightly to a network location and is working as planned. My issue is that it creates a new .bak file with each backup (as I want it to) but after running for two weeks I have 14 .bak files. Is there an easy way to have the job also delete old .bak files that are older then 7 days?

I don't know any SQL scripting or coding so if there is a way to do this from the GUI that would be ideal.

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of Simone B
Simone B
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The .bak backup files are just files - they're not referred to in any database or anything - so you can just go to that directory and delete whichever ones you want to get rid of, using Windows Explorer!

You could add code into the backup maintenance plan (it's an SSIS package) to delete any files older than 7 days - is there someone in your organisation who writes SSIS packages?
Avatar of AIC-Admin

ASKER

I am sure that I could ask our SQL programmer to do write a SSIS package but I was trying to just finish the task myself. I know I can delete them via explorer but the idea is automation so I don't have to manually delete the files or worry about forgetting to clean them up and eating up disk space.

I will check the "Maintenance Cleanup Task" that buttercup1 suggested... I must have totally over looked that. Thanks
Since I already had the plan in place I just added a Subplan to run the Maintenance Cleanup Task and set it to delete files with extension bak from the network backup location that are older then 7 day(s). Thank you for the guidance!
You're welcome!