ChetOS.net

TFS Transaction Log Backups

You can configure TFS to do backup if you install the TFS Power Tools.  One configuration is to backup the transaction log every 15 minutes.  The problem is that the backup does not truncate the log file and therefore you end up taking a backup of the hundreds of megs of transaction log every 15 minutes.

The SQL that is executed to do a transaction log backup is something like:

BACKUP LOG [Tfs_DefaultCollection] TO DISK = N'\\TFSDB\TFSBackup\Tfs_DefaultCollection_20101202142822L.trn' WITH NO_TRUNCATE , DESCRIPTION = N'Tfs_DefaultCollection database - Log Backup', RETAINDAYS = 7, NOFORMAT, NOINIT, NAME = N'Tfs_DefaultCollection database Backup', NOSKIP, REWIND, NOUNLOAD, STATS = 10

Notice the WITH NO_TRUNCATE predicate.  This needs to be removed in order to backup properly.

I dug into the assemblies with Reflector and ildasm and a slight tweak to the "Microsoft.TeamFoundation.PowerTools.Admin.dll" assembly (version 10.0.30831.0) will let you remove NO_TRUNCATE. The file is located in C:\Program Files\Microsoft Team Foundation Server 2010 Power Tools\Team Foundation Server Backup Plan\

Using a hex editor (like XVI32), goto position 0x9709 from a 17 to an 18.  This has the effect of changing the LogTruncation value from NoTruncate to Truncate, which will remove the "NO_TRUNCATE" part of the SQL command.

In the process, your strongly named assembly will no longer validate properly.  This is fine for the TfsConfigPT executable because the modified assembly is in its AppBase path.  In this case, strong name validation is bypassed automatically.

When you load the TFS Management Console, it will not be able to load the modified assembly and you will no longer be able to administer the backup configuration.  This is not good.  In order to get the management console to bypass the validation, you need to copy the Microsoft.TeamFoundation.PowerTools.Admin.dll file into the C:\Program Files\Microsoft Team Foundation Server 2010\Tools directory.  In addtion, you need to make a small change to the registry to change where the management console looks.  Just modify the path in HKLM\SOFTWARE\Microsoft\TeamFoundationServer\10.0\Plugins\Backup\Binary.

This may sound like a lot, but it will only take 5 minutes, and it will save a huge amount of harddrive space.
Posted by Chet at 12:39 PM

Comments

No Comments have been Posted.

Post a Comment

Feel Free To Share Your Thoughts
You can use [b], [u], [i], and [url]
Optional
Name
Website
© 2013 Chet Zema π