Please refer to Setting up an External Database page for the general external database information and the database-specific configuration steps. If you want to start using external database from the first TeamCity start, those are the only steps you need.
This section covers steps you need to perform if you evaluated TeamCity with internal database and need to switch to an external database to prepare your TeamCity installation for production use.
This section covers:
Since TeamCity 5.0, maintainDB command line utility is used to migrate data between databases. maintainDB.[cmd|sh] shall/batch script is located in the <TeamCity Home>/bin directory and is used for migrating as well as for backing up and restoring TeamCity data.
If you were using TeamCity with the internal storage engine, there are two ways to switch to an external database:
- Switch with no data migration: build configurations settings will be preserved, but not the historical builds data or users.
- Full Migration: all the data is preserved except Inspections and Duplicate build results (and any database-stored data provided by the third-party plugins).
|Database migration cannot be combined with server upgrade. If you want to upgrade at the same time, you should first upgrade, run the new version of TeamCity, and then migrate to another database.|
Switching to Another Database
To switch to another database without saving the build history or user data:
- Install and set up an external database.
- Shut down the TeamCity server.
- Create a backup copy of the <TeamCity Data Directory> used by the server
- Clean up the system folder: you must remove messages and artifacts folders from /system folder of your <TeamCity data directory>; you may delete old HSQLDB files: buildserver.* to remove the no longer needed internal storage data.
- Start the TeamCity server.
TeamCity supports HSQLDB, MySQL, Oracle, PostgreSQL, Microsoft SQL Server 2005, 2008 and Sybase; the maintainDB tool can move data between any of these databases.
|The target database must be empty before the migration process (it should NOT contain any tables).|
|If an error occurs during migration, do not use the new database as it can result in database data corruption various errors that can uncover later. In case of error investigate the reason that is logged into console or in the migration logs (see below), and if solution is found, clean the target database and repeat the migration process|
To migrate all your existing data to a new external database:
- Set up an external database to be used by TeamCity. At this point you should only create and configure the database and also install the database driver into TeamCity. Do not modify any TeamCity settings at this time.
- Shut the TeamCity server down.
- Create new properties file with a custom name (for example, database.<database_type>.properties) for the target database according to its settings from a corresponding template (<TeamCity Data Directory>/config/database.<database_type>.properties.dist), entering actual values. Place this file into a temporary directory to your liking.
- Run the maintainDB tool with the migrate command and specify the absolute path to the newly created target database properties file with -T option:
Upon the successful completion of the database migration, a database.properties file will be replaced with the file specified via -T option. The old database.properties file will be automatically re-named in the following format: database.properties.before.<timestamp>.
- Start TeamCity server. This should be the same TeamCity version that was run last time (TeamCity upgrade should be performed as a separate procedure).
Databases Properties Table
| DB Name
|| Driver Class Name
|| Driver jar Name
|| Driver is Bundled
|| JDBC URL format
|| no, download page
|| no, download page
| no, grab files ojdbc14.jar and orai18n.jar from Oracle server installation or download them form download page
| MS SQL
|| no, download page
|| jdbc:jtds:sqlserver://<host>[:<port>]/<database name>
|| no, grab it from <Sybase home directory>/jConnect-6_0/classes
- Extended information during migration execution is logged into logs\teamcity-dbmt.log file. Also, logs\teamcity-dbmt-truncation.log contains extended information on possible data truncations during the migration process.
- If you encounter an "out of memory" error, try increasing the number in the -Xmx512m parameter in the maintainDB script. On a 32-bit platform the maximum is about 1300 megabytes.
Alternative approach is to run HSQLDB in standalone mode via
and then running the Migration tool pointing to the database as the source: jdbc:hsqldb:hsql://localhost/buildserver sa ''
- If you get "The input line is too long." error while running the tool (e.g. this can happen on Windows 2000), please change the script to use alternative classpath method.
For maintainDB.bat, remove the lines below "Add all JARs from WEB-INF\lib to classpath" comment and uncomment the lines below "Alternative classpath: Add only necessary JARs" comment.