To convert files from a SoureGear Vault Standard v3.1.9 to Git including all history I went on a journey and in this blog post I will describe the journey steps.
Note: this blog post will probably contain unnecessary steps, but non the less it describes the steps how I successfully converted all files found in a SourceGear Vault Standard v3.1.9 server to Git, including all history.
Steps
Notes
- The SourceGear Vault Standard v3.1.9 was installed on a Microsoft Windows 2003 32bit Server.
- On the server was a Microsoft SQL Server 2005 32 bit installation.
- During the upgrade I switched to a Windows 10 (64 bit) Hyper-V machine.
- To prevent “multi user” sql connection problems, make sure you stop the vault service with a iisreset /stop, before installation.
- All developers should checkin their files on the SourceGear Vault Standard v3.1.9 server.
- Verify that no files are checked out with the Vault Standard v3.1.9 admin tool.
- If you are using SQL Server 2005 make sure that the database sgvault is in SQL Server 2005 compatibility modus
Steps on the Microsoft Windows 2003 32bit Server
- For the conversion, I added the SourceGear Vault Service IIS application pool user, to the local administrator group.
- Our Vault Service connects to SQL Server by using windows authentication. I added the sgvaultuser, Network Service and the locale user that was executing the setups to the SQL Server sysadmin group for the conversion.
- At the end of the following installs don’t install the Vault Client
- Download and install http://download-us.sourcegear.com/Vault/3.5.3.5169/VaultServer_3_5_3.msi
-
Download and install http://download-us.sourcegear.com/Vault/4.0.6.15954/VaultServer_4_0_6_15954.msi
-
If this upgrade fails on setting foreignkeys for table tblcheckoutlistitems, then check this
-
-
Download and install http://download-us.sourcegear.com/Vault/4.1.4.18402/VaultServer_4_1_4_18402.msi
-
Download and install WIC https://www.microsoft.com/en-us/download/confirmation.aspx?id=32
-
Download and install .net 3.5 http://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe
-
Download and Install .NET 4.0 https://www.microsoft.com/en-us/download/confirmation.aspx?id=17718
-
Note: this takes a while on Windows 2003 server.
-
-
Download and install http://download-us.sourcegear.com/Vault/5.0.4.18845/VaultServer_5_0_4_18845.msi
-
Download and install http://download-us.sourcegear.com/Vault/5.1.2.19281/VaultServer_5_1_2_19281.msi
-
Download and install http://download-us.sourcegear.com/Vault/6.1.0.531/VaultServer_6_1_0_531.msi
-
Backup the SQL Server 2005 databases: sgmaster, sgnotify, sgvault, sgvaultindex
Steps on the Microsoft Windows 10 64bit Hyper-V virutal machine
The following steps were executed on an empty Microsoft Windows 10 (64 bit) Hyper-V virtual machine.
-
Turn the Windows IIS feature on (including all sub features)
-
Install SQL Server 2014 (64 bit)
-
Create databases on SQL Server 2014: sgmaster, sgnotify, sgvault, sgvaultindex
-
Restore the databases on SQL Server 2014 from the SQL Server 2005 backups: sgmaster, sgnotify, sgvault, sgvaultindex
-
Set compatibility modus to SQL Server 2014 for the SQL Server 2014 databases: sgmaster, sgnotify, sgvault, sgvaultindex
-
Execute SQL “login / user” correction script, found at: http://support.sourcegear.com/viewtopic.php?t=924
-
Download and install http://download.sourcegear.com/Vault/9.0.0.452/VaultServer64_9_0_0_452.msi
-
Install the Vault Client
-
Verify we have a working Vault Standard v9.0.0 installation.
Git
-
Install Git https://git-scm.com/downloads in my case it was v2.6.4 Git for Windows.
- During installation make sure, you choose: “Run Git and included Unix tools from the Windows Command Prompt”.
- Intialize Git, set username and email
- Create a folder “C:\Projects\Git\MyRepo”
- Create a GIT repository inside “C:\Projects\Git\MyRepo” by executing: git init.
-
Commit one file (e.g. an .ignore file) to the MyRepo master with a initial commit.
-
IMPORTANT, do a GET of all Vault files to this MyRepo folder, making all files writable
Vaut2Git
-
Install Visual Studio 2015 community edition
-
Download the vault2git tooling https://github.com/AndreyNikiforov/vault2git/archive/master.zip
-
Extract the zip file and open the solution with Visual Studio 2015 community edition.
-
Download the Client API belonging to Vault v9.0.0 http://download.sourcegear.com/VaultPro/9.0.0.30452/VaultProClientAPI_9_0_0_30452.zip
-
Extract the files from the Client API zip
-
Copy the folder to the Vault2GitLib/libs folder and adjust the references
-
Build the solution in release modus.
Now the really import part is adjusting the App.config file
Vault.Server
The servername, because I am running the vault2git tool on the vault server this is localhost.
Vault.User
The vault user name used to login to the SourceGear Vault.
Vault.Password
The vault user password used to login to the SourceGear Vault.
Vault.Repo
The Vault repository name, to get the files from
Git.DomainName
This is the part that will be added to each Vault username to create a Git user email from a Vault username.
Convertor.WorkingFolder
This folder must be the Git repository root folder.
This folder should contain a “.git” folder, before the vault2git is run.
Convertor.GitCmd
The path to the git.exe to use.
Convertor.Paths
At first this is a “;” seperated list of conversions.
Each conversion is a “~” seperated key value pair.
The first part of the conversion is the path in the Vault (in this case the root of the vault “$”).
The second part of the conversion is the Git branch (in this case “master”)
In this case only one conversion is done, namely converting all the files from a Vault respository to a Git repository branch called master.
NOW RUN THE vault2git.exe
It should convert all files from vault to git
note that this takes a long time.
In my case 7MB of Vault Source files took 23 minutes to convert!!
Bitbucket
Now that we have a locale Git repository containing all Vault Sources and history, we can push this Git respository to a remote Git respository (in our case a Bitbucket service).
-
Create a Git repository in bitbucket.
-
Add users to the Git repository
-
Adjust the client_max_body_size (we set it to 0) in the files:
-
/etc/nginx/nginx.conf (Use sudo vim, else the file will be read-only)
-
/etc/nginx/sites-available/bitbucket-cache
-
This is to allow large commits
-
-
Adjust postBuffer: git config –global http.postBuffer 1048576000
-
This is to allow large commits (<= 1GB)
-
Some additional information and Notes
Moving vault databases
http://support.sourcegear.com/viewtopic.php?t=924
Vault upgrade guide
http://kb.sourcegear.com/VaultHelp/viewtopic.php?f=13&t=11648
Vault compatibility chart
http://www.sourcegear.com/vault/documentation/compatibility_chart.html
SQL “login / user” correction script
USE [master]
IF ( NOT EXISTS (SELECT sid FROM syslogins WHERE name = ‘sgvaultuser’) )
CREATE LOGIN sgvaultuser WITH PASSWORD = N’VAULTS_ADMIN_PWD’, DEFAULT_DATABASE = sgvault, CHECK_POLICY = OFF;
GO
— next access should be granted in the vault database
USE [sgvault]
EXEC sp_grantdbaccess N’sgvaultuser’
EXEC sp_addrolemember N’db_owner’, N’sgvaultuser’
GO
— The following is ONLY for Fortress and VaultPro:
USE [sgdragnet]
EXEC sp_grantdbaccess N’sgvaultuser’
EXEC sp_addrolemember N’db_owner’, N’sgvaultuser’
GO
— The following is for Vault 4.x and above or Fortress and VaultPro:
USE [sgmaster]
EXEC sp_grantdbaccess N’sgvaultuser’
EXEC sp_addrolemember N’db_owner’, N’sgvaultuser’
GO
Rollback
In my case, something went wrong and I had to rollback from 4.0.6 to 3.1.9.
If you have to restore a old database, make sure you first remove all sofware.
Remove alle databases.
Create a new sgvault database.
Restore the backup to this new sgvault database.
Hello Roel,
Thanks for the blog post. I have few issues while trying this out. Hope you would be able to guide me
I am accessing the vault server via network. Its not on my local machine. I have changed the setting accordingly in app.config. Currently I am not looking at the Database migration. Only the source code in my vault server.
How do I adjust references & which vault2git exe to run?
D:\Users\khydesai\Desktop\Downloads\exe\vault\vault2git-master\vault2git-master\Vault2GitCLI\bin\Release
or
D:\Users\khydesai\Desktop\Downloads\exe\vault\vault2git-master\vault2git-master\Vault2GitCLI\obj\Release
Dag Roel,
Thanks for posting this, it helped me a lot! I am really thankful for explaining in more detail how the Convertor.Paths should be.
Still, I do not have it running, I get this error: “Unhandled Exception: System.InvalidOperationException: Sequence contains no elements”
I traced this back in processor.cs to: currentBranch = msgs.Where(s => s.StartsWith(“*”)).First().Substring(1).Trim();
When I changed this code to currentBranch = “master”
then it suddenly works. So, is the code wrong or is my config file wrong, which simply contains this path:
Any ideas?
Thanks, André