You are viewing the documentation of TeamCity 2018.x, which is not the most recently released version of TeamCity.
Go to the latest TeamCity documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.

Skip to end of metadata
Go to start of metadata

TeamCity administrators are able to restore backed up data using the maintainDB command-line utility.

Server Copying


If you are creating a copy of the server, make sure to go through copied server checklist after restoration.

On this page:

You can restore backed up data into the same or a different database; from/to any of the supported databases (e.g. you can restore data from a HSQL database to a PostgreSQL database, as well as restore a backup of a PostgreSQL database to a new PostgreSQL database).
A newer version of TeamCity can be used to restore the backup created with any previous TeamCity version (provided that TeamCity version is not before TeamCity 6.0).

During database restoration you might want to configure database-specific settings to make the bulk data changes faster (like setting SQL Server "Recovery Model" to "Simple").

A TeamCity backup file does not contain build artifacts, so to get the server with all the same important data you need to restore from a backup file (at least settings and database) and copy the build logs and artifacts (located in <TeamCity Data Directory>/system/artifacts by default) from an old to the new data directory manually. The general compatibility rule of the data under system/artifacts is that files created by older TeamCity versions can be read by newer versions, but not necessarily vice versa.
When external artifacts storage is enabled, the artifacts directory of the TeamCity Data directory contains metadata about artifacts mappings, so make sure they are restored.

See also details on the directories in the TeamCity Data Directory description.

Performing restore

(info) This document describes only some of the maintainDB options. For the complete list of all available options, run maintainDB from the command line with no parameters. See also maintainDB startup options.

To perform restore from a backup file:

  1. Install the TeamCity server from a tar.gz or .exe installation package. Do not start the TeamCity server.
  2. Create a new empty TeamCity Data Directory.
  3. Select one of the options:
    1. To restore the backup into a new external database, create and configure an empty database, configure a database.properties file with the database settings to be passed to the restore command later on and either place it into the /config subdirectory of the newly created TeamCity Data Directory or anywhere on your file system outside the TeamCity Data Directory.

    2. To restore the data into the same database the backup was created from, proceed to the next step.

  4. Place the required database drivers into the lib/jdbc subdirectory of the newly created TeamCity Data Directory directory.
  5. Use the maintainDB utility located in the <TeamCity Home>/bin directory to run  the restore command:

    1. To restore the backup into a new external database
      - if the  database.properties file is in the TeamCity Data Directory:

      - If the database.properties file is outside the TeamCity Data Directory:

    2. To restore the data into the same database the backup was created from:

    3.  To restore the backup into the internal database:

  6. If the process completes successfully, to complete the restoration you need to copy over <TeamCity Data Directory>/system/artifacts from the old directory. The directory stores build artifacts and those are not included into the backup file.


Notes on the restore command options:

  • The -A argument can be omitted if you have the TEAMCITY_DATA_PATH environment variable set.
  • The -F argument can be an absolute path or a path relative to the <TeamCity Data Directory>/backup directory.
  • The -T argument must point to the database.properties file created in step 3.
  • If the -T argument is not specified and the database.properties file is present in the newly created TeamCity Data Directory/config and the backup file,  the database is restored using the properties file in TeamCity Data Directory/config.
  • By default, if no other option except -F is specified, all of the backed up scopes will be restored from the backup file. To restore only specific scopes from the backup file, use the corresponding options of the maintainDB utility: -D, -C, -U, -L, and -P.


To get the reference for the available options of maintainDB, run the utility without any command or option.

Restoring database only

When restoring the database but preserving the more recent TeamCity Data directory, it is important to make sure the data is consistent, so:

  • <TeamCity Data Directory>/system/pluginData ("supplimentary data") should be restored as well to be consistent with the database-stored data;
  • <TeamCity Data Directory>/system/caches should be cleared before the server start.

Before restoring a TeamCity database to an existing server, make sure the TeamCity server is not running.

To restore a TeamCity database only from a backup file to an existing server:

  1. Create and configure the database, placing the database.properties file into the config subdirectory of the TeamCity Data Directory.
  2. Ensure that the required database drivers are present in the TeamCity Data Directory/lib/jdbc sub directory.
  3. Use the maintainDB utility located in the <TeamCity Home>/bin directory (only available in TeamCity .tar.gz and .exe distributions).
  4. If "supplementary data" is present in the backup, delete the content of <TeamCity Data Directory>/system/pluginData directory (consider backing it up into another file system location first).
  5. Use the restore command (The -T argument must point to the database.properties file created in step 1):

  6. See the maintainDB utility console output. You may have to copy the database.properties file manually if requested.
  7. Delete the content of <TeamCity Data Directory>/system/caches directory.

Resuming restore after interruption

The restore may be interrupted due to the following reasons:

  • Lack of space on the file system or in the database
  • Insufficient permissions to the file system or the database.

The interruption occurs when one of tables or indexes failed to be restored, which is indicated in the maintainDB utility console output.
Before resuming the restore, manually delete the incorrectly restored object from the database.

To resume the backup restore after an interruption:
Run the maintainDB utility with the restore command with the required options and the additonal --continue option:

See also:

1 Comment

  1. Production Teamcity version - 10.0.5, Postgres - 9.x . I want to migrate data to new environment set up using docker pull in photon linux machine. Which method should I use for data migration. The current full database backup size is 7.5 to give estimate with lot of custom parameters, builds - c++, java using docker microservices, ruby etc.

    New Teamcity - 2018.1.2 Postgres 10.5

    Please provide examples in this page for clarity. Thanks.