How do I connect Teamcity to an existing SQLServer 2005 database
-
06-07-2019 - |
Question
We had a machine that run teamcity 4.0.2 and that used SqlServer 2005 as datastore. The machine crashed, but we still have the database. How can I get a newly created instance of teamcity connected to the database?
I found infos about migrating an existing teamcity installation over to a new database. But thats not what I want.
EDIT: I thought that the database contains the configuration for the projects. Thats not the case: Its in the folder Configuration of the Teamcity data directory (.BuildServer)
I only had to copy the contents of that folder over to my new installation. I guess my question was wrong. Anyway I leave it as it is, because there might be others who have the same idea.
Solution
Download the MSSQL driver and copy it to WEB-INF/lib of your TeamCity install (probably under program files if you're running Windows).
Create a file called database.properties in your config directory (under Windows it's usually Documents and settings\user_who_ran_install.buildserver\config) and put the following lines into it:
driverName=net.sourceforge.jtds.jdbc.Driver connectionUrl=jdbc:jtds:sqlserver://:1433/ connectionProperties.user= connectionProperties.password=
maxConnections=50 poolPreparedStatements=true
Restart TeamCity Web Server service. There's a nonzero chance it won't come back up or will be unreachable. Follow the instructions here to the letter and you should be OK. Make sure to have a backup of your database available in case TeamCity decides to reinstall all the data objects for some reason.
OTHER TIPS
Start TeamCity using the internal database so that the TeamCity configuration directory is recreated (unless you have a backup of that already).
Then shut down TeamCity and copy the database driver (latest version is jtds-1.2.2.jar) to TeamCity\webapps\ROOT\WEB-INF\lib
and create the database.properties file in .BuildServer\config\database.properties
:
driverName=net.sourceforge.jtds.jdbc.Driver
connectionUrl=jdbc:jtds:sqlserver://192.168.1.99:1433/TeamCityDB
connectionProperties.user=teamcity_user
connectionProperties.password=teamcity_passwd
maxConnections=50
poolPreparedStatements=true
Restart TeamCity and you should be good to go.
I don't know how team city works, so I might not have the best answer. However could you not try backing up the DB, reinstalling team city and then restoring the backup DB over the instance created by teamcity?
I had a similar problem with TeamCity 9.1 and SQL Server 2012. Our TeamCity was ok but db was unreachable. We had to restore a backup copy of the db to another server and then point TeamCity to it. In order to point TeamCity to the db on the new server we needed to modify the database.properties file in C:\programData\JetBrains\TeamCity\config. Then restart the TeamCity services on the build machine. After that TeamCity was able to come up just fine.