Skip to content

Instantly share code, notes, and snippets.

@pretorh
Last active November 8, 2023 12:57
Show Gist options
  • Save pretorh/77e34b47578f73890296 to your computer and use it in GitHub Desktop.
Save pretorh/77e34b47578f73890296 to your computer and use it in GitHub Desktop.
Summary of steps required to migrate Teamcity database to a Postgres db on mac

Teamcity references (follow these/updated versions, use below as summary)

The steps are based on zsh history, so there might me some missing.

Directory locations

TeamCity Data Directory

/private/var/root/.BuildServer
Go to Teamcity > Admin > Global Settings and look for the directory labeled "Data directory"
Alternative: sudo find / 2>/dev/null | grep .BuildServer/config

TeamCity Home

/Library/TeamCity/
find / 2>/dev/null | grep TeamCity-readme.txt

Postgres

Installation of Postgres mostly based on http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/ and from brew install's output

brew install postgresql
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Setup Postgres:

psql template1
template1?

CREATE DATABASE teamcity;
CREATE ROLE teamcityuser;
ALTER ROLE teamcityuser WITH PASSWORD 'password123'

Test database access
psql -d teamcity

Install jdbc:

This will depend on the java version (java -version)

cd /private/var/root/.BuildServer/lib/jdbc
curl https://jdbc.postgresql.org/download/postgresql-9.4-1201.jdbc41.jar -O

Migrate

Stop Teamcity:
launchctl stop jetbrains.teamcity.server

create a copy of the Postgres sample file and edit it

cp /private/var/root/.BuildServer/config/database.postgresql.properties.dist /tmp/database.properties
vim /tmp/database.properties

set the hostname to localhost, keep the default port, set the database name. Set the username and password

...
connectionUrl=jdbc:postgresql://localhost:5432/teamcity
connectionProperties.user=teamcityuser
connectionProperties.password=password123
...

run the migration script included in Teamcity:
/Library/TeamCity/bin/maintainDB.sh migrate -A /private/var/root/.BuildServer -T /tmp/database.properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment