Minimize your TFS Backup size


As I mentioned in a previous post, it’s now easier than ever to backup your TFS databases using the Team Foundation Server Backups feature in the Team Foundation Server Power Tools September 2010 release.

I have TFS Basic running on my laptop and use it as my ‘SourceSafe replacement’. It gives me version control and work items. That’s all I need it for in this instance. As a backup solution, I perform a  full backup every day and this syncs to my preferred backup service in the cloud. I noticed that my backups were considerably large though, and increasing by a few Mb every day. It reached the stage where I was backing up 290Mb+ per day. Even with moderately fast broadband, this is a painful upload. The odd thing was that I wasn’t making a whole lot of use of my TFS Basic instance recently, yet it grew from 200 to 290Mb over a few days.

After a bit of investigation it turned out that the Transaction log is to ‘blame’. The TFS databases are set to a Recovery Model of FULL. This is by design and is aimed at limiting the loss of data if you ever need to restore from backups. for more info on Recovery Models, see Choosing the Recovery Model for a Database

Now I would argue that your basic user who wants a ‘SourceSafe replacement’ running locally shouldn’t have to worry about backing up or shrinking transaction logs so that they can minimize their backup sizes. In fact, if the user is performing a FULL backup, it would be great if the Power Tool wizard provided the ability to maintain or ‘flush’ the transaction log.

There is some very healthy debate on the internet with regards to shrinking log files and it’s generally considered better practice to back them up. BUT, I’m doing full backups, I don’t need point in time recovery, I just want a quick and dirty backup! How hard can that be? Not very hard at all. All we need to do is backup the  log to a non existent location, or NULL.

Create a SQL Job and set it to run before your TFS Backups. All this job should run is the following:

USE master
GO

BACKUP  LOG [Tfs_Configuration] TO DISK = ‘NULL’
BACKUP  LOG [Tfs_DefaultCollection] TO DISK = ‘NULL’
GO

I ran this on my system and my backup has gone from 294Mb to 164Kb. That’s a backup that is very happy to upload to the cloud! Please note, try this at home, this is intended for non-critical systems, not on your company systems, which should have full and partial backups appropriately scheduled to minimize data loss.

An alternative to this is to change your TFS databases to use a Simple Recovery Model.

Thanks to Simon Sabin for his help on this issue.

Mike

Advertisements

3 Replies to “Minimize your TFS Backup size”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s