Monday, May 25, 2009

VSS => TFS Migration

Now that I have the TFS installed to play with, my next task is to come up with the process to transfer existing projects from Visual Source Save. Since the current VSS database is fairly huge, and we do not want to transfer the whole thing at once, I came up with the following process:


  • Select project(s) to be transferred from VSS database

  • Back up project(s) and restore them to the new VSS database

  • Fix the issues in the new VSS database with the Analyze tool

  • Run the VSSConverter tool in analyse mode

  • Get the TFS ready for migration

  • Prepare the migration settings file

  • Run the VSSConverter tool in migration mode

  • Verify the results of the migration

This may look rather lengthy and complex, but it makes sure that the current VSS database remains untouched, which is quite important for obvious reasons.

Here is how I migrated a small project from VSS to TFS in a few more detail:

Select project(s) to be transferred from VSS database

Let's say we want to transfer MySmallProject which is located in $/MyMiscProjects/MySmallProject in a large VSS database.

Back up project(s) and restore them to the new VSS database

Microsoft has two utilities for backing up and restoring VSS projects, SSARC and SSRESTOR. Their parameters are described in detail here:

SSARCSSRESTOR

They usually can be found in the SourceSafe folder (i.e. C:\Program Files\Microsoft Visual SourceSafe)

First, I create a new VSS database (VSSTransfer) where I'm the admin. Next, I need to have admin rights in the initial VSS database and, of course, to know where it is located. Then I can run the SSARC command like that:

ssarc -d- -i -yadmin,password -s\\PathToVSSDB\MyHugeVSSDB CodeProject.ssa "$/MyMiscProjects/MySmallProject"

This backs up the MySmallProject with default parameters, without deleting files from the old database "MyHugeVSSDB", into the CodeProject.ssa archive file.

Next, I restore the project into the new empty database I created.

ssrestor "-p$/MySmallProject" -sC:\VSSTransfer -yadmin,password CodeProject.ssa "$/MyMiscProjects/MySmallProject"

Fix the issues in the new VSS database with the Analyze tool

This is just running the Analyze tool with the -F parameter to fix possible issues in the VSS.

Run the VSSConverter tool in analyse mode

The VSSConverter is a Microsoft tool that comes with the TFS and allows migrating data from VSS database into the TFS database. More info here:

VSSConverter Command-Line Utility for Source Control Migration

To run the VSSConverter, a settings file has to be prepared first. Here is the sample:














(if we need to transfer multiple projects, there can be multiple 'Project' elements under 'ProjectMap')

Now I save the file as settings.xml and run the VSSConverter tool (which is located in drive:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE ):

VSSConverter analyze settings.xml

(An important note, though - the VSSConverter should be the one that comes with TFS SP1. I tried to use the tool from the original TFS install and got troubles with history - it was not migrated at all).

Two files will be created, Analysis.xml and UserMap.xml

Get the TFS ready for migration

First of all, create the target project, i.e. MyTFSSmallProject. Then, look at the UserMap.xml. It lists all VSS users who performed action in the database. It looks like this:


xmlns:xsd="http://www.w3.org/2001/XMLSchema">




To map users properly, we need to add them to TFS. If the user no longer exists, he can be mapped to any user - TFS admin or his team leader, for example. So the UserMap.xml will end up looking like this:


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">




Prepare the migration settings file

Modify the settings.xml file to specify the SQL Server that is going to be used for the migration process and Team Foundation Server, the users map file and the destination project on the TFS as follows and save it as migration_settings.xml. The SQL server does not have to be the one where TFS database are located, and the user performing the migration need to have CREATE DATABASE permission in the SQL Server.


















Run the VSSConverter tool in migration mode

Run the VSSConverter tool in migration mode as follows:

VSSConverter Migrate migration_setting.xml

A report file called VSSMigrationReport.xml will be created if the migration process runs successfully. A log file called VSSConverter.log will contain information messages about the migration process.

Verify the results of the migration

Log in to TFS, go to the project's Source Control Explorer, check the files, history etc. Get the latest version, build it. Have fun.

No comments: