JetBrains / teamcity-docker-server

TeamCity server docker image sources
https://hub.docker.com/r/jetbrains/teamcity-server/
Apache License 2.0
72 stars 52 forks source link

The source database is currently used by a running server #36

Closed ChrisScottThomas closed 5 years ago

ChrisScottThomas commented 5 years ago

I'm trying to migrate a database from teamcity 10.0.5 (bare metal) to 2019.1.1 (Kubernetes) I've managed to export the data from 10.0.5, and import to the DB attached to the 2019.1.1 pod. The issue now is that the server is running 878 and the database is 787

Software schema version: 898
Source database schema version: 787

I've tried to follow the guidance to migrate the database, I start the pod with teamcity-server not running yet I get errors saying that the database is connected to a running server.

See output below:

root@teamcity-server-9c688b5d8-k8kvh:/# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 08:03 ?        00:00:00 /bin/bash
root        30     0  0 08:03 ?        00:00:00 bash
root        52    30  0 08:03 ?        00:00:00 ps -ef
root@teamcity-server-9c688b5d8-k8kvh:/# cd /opt/teamcity/bin/
root@teamcity-server-9c688b5d8-k8kvh:/opt/teamcity/bin# ./maintainDB.sh migrate -T /tmp/database.migration.properties.dist
../webapps/ROOT/WEB-INF/lib
Picked up JAVA_TOOL_OPTIONS: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
Using logs directory "/opt/teamcity/logs"
TeamCity maintenance tool. Copyright 2006-2019 JetBrains s.r.o. All Rights Reserved.

Command line arguments: migrate -T /tmp/database.migration.properties.dist
The TeamCity Data Directory path is determined using the environment variable TEAMCITY_DATA_PATH
Using TeamCity data directory: /data/teamcity_server/datadir
Using database settings from the TeamCity data directory for source database: /data/teamcity_server/datadir/config/database.properties
Using source database
    database type: POSTGRESQL
    connection string: jdbc:postgresql://teamcity-psql:5432/teamcitydb
Source JDBC driver version 42.2 (PostgreSQL JDBC Driver)
Source database system version 11.4 (PostgreSQL)
Sharing the source database with a running server.
Source database metadata version: 2
Software schema version: 898
Source database schema version: 787
Cannot proceed with 'migrate' command: The source database is currently used by a running server,
and schema versions don't match exactly - could not backup in this case.
In order to backup, use the maintainDB tool from the current installation, or shut down the TC server before backup.
Critical error has occurred during command execution.

No idea why it thinks teamcity server is connected? Is there another way I can upgrade the database so it's compatible with 2019.1.1?

dmitry-treskunov commented 5 years ago

Hi, you just need to start the TeamCity 2019.1.1 with the database from 10.0.5, open the Web UI and perform the upgrade of the data from the Web UI.

ChrisScottThomas commented 5 years ago

There is no option to 'upgrade' the data...

TeamCity has failed to start

TeamCity server startup error

Version mismatch: Data format of the data directory (898) and the database (787) do not match.
Please ensure that the data directory and the database in use were upgraded/restored consistently and were always used together. 
See details at https://www.jetbrains.com/help/teamcity/2019.1/?Upgrade.

Current Startup State
Startup status
Current step: TeamCity server startup error
Next step: not defined yet
Data Directory

Directory path: /data/teamcity_server/datadir exists

Database properties file exists

Internal database file: not found
Database

Database type: POSTGRESQL

Database connection URL: jdbc:postgresql://teamcity-postgres-old:5432/teamcitydb

JDBC driver version: 42.2 (PostgreSQL JDBC Driver)

Database system version: 11.4 (PostgreSQL)
Versions

Software version: 898

Data directory version: 898

Database version: 787
Logs

Logs path: /opt/teamcity/logs
dmitry-treskunov commented 5 years ago

Ah ok, so you started TeamCity using the fresh Data Directory and an old database. You need to backup/restore both data directory and database to the 2019.1.1 pod

ChrisScottThomas commented 5 years ago

yep that's fixed it. Had to tar up each individual folder so that I didn't carry over the 200GB of artifacts & cache.

Thanks :)