Saturday, 04 February 2012 23:39

Automatically remove old backup files

Written by 
Rate this item
(6 votes)

At my company we are running over 10 BizTalk development and test servers. On those servers I enabled the SQL Server BizTalk backup job. I do not however want to manually delete old backups of BizTalk databases for all those servers. I want those old backups deleted automatically. This will prevent the database files from growing indefinitely (or till your disk is full…). Also, on my production servers I do not want old backups files to take up all free disk space and cause incidents. To automatically remove old backup files I use a maintenance plan. This blog post shows you how to create this maintenance plan.


For this example I used SQL Server 2008 R2. I configured the Backup BizTalk Server (BizTalkMgmtDb) job to make backups to the following locations:
F:\backup\full
F:\backup\log


Open SQL Server Management Studio and connect to your instance where the BizTalk databases are running. Open Management and right-click Maintenance Plans and click Maintenance Plan Wizard.

automatically remove old backup files 1

Click on Next

automatically remove old backup files 2

Give your maintenance plan a name. I used Remove old backups. Click on change to set up a schedule.

automatically remove old backup files 3

In this example I set the maintenance plan up to run daily. This does not mean that all files older than a day will be deleted. We will get to that later. This just means that the maintenance plan will run daily. If you set your schedule click OK.

automatically remove old backup files 4

Click in Next.

automatically remove old backup files 5

Select Maintenance Cleanup Task and click on Next.

automatically remove old backup files 6

Click on Next.

automatically remove old backup files 7

Select the folder where your backups are written to. In this example that folder is F:\backup. I selected Include first-level subfolders because the actual backups are written to F:\backup\full and F:\backup\log. The file extension of my backup files is bak. This is the default. In this example I want files older than a day old to be removed. This is what I normally do on development and test servers, because there is no real need to backup data. On production servers I also normally choose one day. Not that data is not important on production servers, but mostly a backup of the server is made during the night.

automatically remove old backup files 8

Choose if you want to have a text report or a report mailed and click on Next.

automatically remove old backup files 9

Click on Finish for the maintenance plan to be created.

automatically remove old backup files 10

Your maintenance plan should now correctly be created. Click on Close.

automatically remove old backup files 11

 This is just one of those steps that makes the life of an admin easier and frees up some time for more important issues.

Read 8359 times Last modified on Saturday, 04 February 2012 23:58
Jeroen Hendriks

Jeroen Hendriks started his career in 2005 as a middleware administrator. One of the products he was responsible for was BizTalk Server 2004. Since that time he mainly focusses on designing, implementing and supporting BizTalk Server infrastructures. Currently he works as a consultant for Axon Olympus. He hopes that his day-to-day experiences will result in useful and practical blog posts. His certifications are MCSE, Certified Ethical Hacker, MCITP: Enterprise Administrator, Server Administrator and Database Administrator 2008.

twitterlinkedin

Website: www.axonolympus.nl

4 comments

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.