Tuesday, October 14, 2008

VSS to SVN Migration

One of my friends convinced me to migrate to SVN. My biggest doubt was file level permission control, but soon discovered that I could mimic that by implementing permission on branches. So the next step was to convert my VSS databased to SVN. After days of trying different solutions, the one that (almost) worked is described here. Thanks to guys at poweradmin.com and others who enhanced their tool. I had to make a change to get one of tools to work with US date/time values. Checkout the bottom for a list of references.

The following have been tested on Windows XP SP2 with VSS 6. The migrated repository was then moved to Windows 2003 server.

So, here are the steps:
I would do this process on a PC (and not a server) first. Then copy the repository to the destination server.

Install SVN Server:
- If you don't have an SVN server, try
VisualSVN.

Create a migration directory structure:
Create a folder structure like this:
C:\TestMigration
C:\TestMigration\Temp
C:\TestMigration\Proj1\VSS_DB
C:\TestMigration\Proj1\Tool

Copy VSS database:
- Before copying, try to check in all files to VSS or as many as you can.
- Making a copy is easy, just copy the VSS directory structure (at the OS level, using Windows Explorer). Copy it to C:\TestMigration\Proj1\VSS_DB.

Clean up the database:
In this step, you want to purge all deleted files from VSS. That may not be necessary, but it helped my migration to go a little faster. You can do one of the following:
- From VSS client, go to each folder, right click and go to properties, select "deleted items" tab, and press purge deleted. This may be time consuming if you're database has a lot of folders.
- You can download an install AxTools VssRecursivePurge (
http://www.softpedia.com/get/Programming/Other-Programming-Files/AxTools-VssRecursivePurge.shtml).
- When running AxTools VssRecursivePurge, end the path with \SRCSAFE.INI or it will crash with an confusing message: "The SourceSafe database path {your user name} does not exist. Please select another database."

Analyze and fix VSS database:
Go to command prompt and run this:
C:\Program Files\Microsoft Visual Studio\VSS\win32\ANALYZE.EXE -f -c -d -v1 C:\TestMigration\Proj1\VSS_DB

Upgrade your VSS 6 to the latest version:
- Your PC must have VSS installed.
- Check Help/About of VSS client. It should be version 6.0d
- Or read this:
http://support.microsoft.com/kb/153925/EN-US/ which states "to determine if your Visual SourceSafe 6.0 database has been upgraded to the new database format check your Visual SourceSafe data directory for a file named Crcs.dat and a subdirectory named Labels. "

Download the Migration Tool:
- If you are in US and you and 11-01-08 means 'Nov 01 2008' to you, download
my revision here. If 11-01-08 means '08 January 2011' to you, Karl's version may work better for you.

Extract the migration tool to C:\TestMigration\Proj1\Tool

Create an SVN user and an SVN repository:
- Create a repository (i.e. TestMigration) . In VisualSVN, right click on "Repositories" and select "Create new repository". Check "Create default structure" and press OK.

- Create an SVN user (e.g. VssMigrate, password abcdefg). In VisualSVN, right click on "Users", select "Create User" and enter user name and password.

Setup the configuration file:
Change the config.ini that comes with the VssMigrate download. Here's the content that matches our folder structure:

[Settings]VSSWIN32=C:\Program Files\Microsoft Visual Studio\VSS\win32 # VSS\Win32 directory which contains ss.exe

VSSDIR=C:\Vss2SVN_Migration\Testing\VSS_DB\ #VSS repository directory (contains srcsafe.ini) . Use environment variable SSDIR to set the current repository (see run.bat below).

VSSPROJ=$/SourceCode #VSS project to start at (ie $/SourceCode). Do NOT use root ($/), but migrate one top folder at a time

VSSUSER="UserName" #This is a VSS user name with full control.
VSSPASSWORD="xxxx" #Use the password for the VSSUSER above

SVNWIN32=C:\Program Files\VisualSVN Server\bin # SVN\bin directory which contains svn.exe

SVNUSER="VssMigrate" #This is an SVN user. All files will be migrated under this user name. Make sure this user is already created in SVN

SVNPASSWORD="xxxxxx" #password of the SVNUSER

SVNURL=http://yourservername:8080/svn/TestMigration/trunk #URL to use for the root of the check in


SVNPROJ=$/SourceCode #Target folder under SVN. This will be created under the SVN URL. It may be best to name it similar to the VSS PROJ

WORKDIR=C:\Vss2SVN_Migration\Temp #Directory under which files and directories will be created as work progresses

DEBUG=1 #turn on debug output, blank is

OKAUTORETRY=0 #if a command fails to run, it will be run automatically 1 time before failing

Create a batch file to run the program:
Create a file in C:\TestMigration\Proj1\Tool and name it run.bat. If you followed the directory structure above, the content of this batch file will be:


set ssdir=C:\TestMigration\Proj1\VSS_DB
VSSMigrate.exe C:\TestMigration\Proj1\Tool \config.ini


Run it!
Go to command prompt and type run.bat to run the program. Depending on your database size, it may take a few hours.

What if it breaks:
If you have to re-run the program, make sure to delete and recreate the SVN repository. Reset your computer time.

Rest the computer date/time:
The migration tool, sets the computer time to the time of each revision. At the end, your computer may end up in a date/time in the past which can cause problems with your virus scan and firewall among others. Reset your computer date/time.