Friday, February 13, 2015

Migrating TeamCity to a new server when using an existing SQL Server

I recently had to move a TeamCity build server because the drive was running out of space.  Therefore, I had to research how to migrate my existing installation of TeamCity to another server or at least be able to re-install TeamCity onto another data drive.

Since I was using SQL Server to store all of my TeamCity data, I figured that the migration should be relatively easy and simple.

Also, I was using TeamCity 9, so I knew I was able to use the Backup option in TeamCity Administration option, but I was wondering if there was another solution.

I searched around for a bit and found this article: https://blogs.endjin.com/2013/07/a-step-by-step-guide-to-migrating-a-teamcity-instance-from-one-server-to-another/

Unfortunately, it details how to migrate from an Internal database to an external database such as SQL Server.  Well, I was already using SQL Server, so how would I migrate then??

I attempted to just change the database.properties file to point to my existing SQL Server database and re-run the setup, but as soon as I did that, I got the following error message:






So that was definitely not going to work!

Well, I decided to simply copy over the entire config directory from my existing TeamCityData directory and re-start the TeamCity Server service. (I didn't need any of the build artifact information carried over)

As you can probably guess, that worked perfectly!!

So, in order to migrate from one server to another when you are using an external database for TeamCity is simply the following:


  1. Re-install the same version of TeamCity on the new server
  2. Copy over the lib\jdbc folder containing the sqljdbc.jar file (needed for SQL Server connectivity)
  3. Shut down the TeamCity Build Agent and Server services
  4. Copy over the config directory (which includes the database.properties file)
  5. Re-start the TeamCity Build Agent and Server services
  6.  Now when you access your new server installation, TeamCity should be up and running with all of your configuration information intact just like before!!
 

2 comments:

  1. Thank you for this! A huge time saver for me tonight as we were doing this exact type of migration. I wish this method was covered in the JetBrains docs :)

    ReplyDelete
  2. Many thanks for your help this is that I was looking.

    ReplyDelete