Icon

You are viewing the documentation of TeamCity 10.x and 2017.x, which is not the most recently released version of TeamCity.
View this page in the latest documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.

 

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: related to https://github.com/JetBrains/teamcity-s3-artifact-storage-plugin/issues/20

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

Note
titlePrevious versions

Note that restoration of the backup created with TeamCity versions earlier than 6.0 can only be performed with the same TeamCity version as the one which created the backup.
Backups created with TeamCity 6.0+ can be restored using the same or more recent TeamCity versions.

...

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.

...

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

A TeamCity backup file does not contain build artifacts, so for the full restore 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) form from an old into to the new data directory manually.

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

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

      temporary

      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.

    3. To restore the backup into the internal database, save the :
      -  TeamCity 10.0.5 and laterproceed to the next step.
      - prior to TeamCity 10.0.5:
      Save the code below to the database.properties file   (this is a temporary file for the purposes of restorerestoration)  and and place the file into any directory other than anywhere on your file system outside the TeamCity Data Directory:.

      Code Block
      # Database: HSQLDB (HyperSonic) version 2.x 
      connectionUrl=jdbc:hsqldb:file:$TEAMCITY_SYSTEM_PATH/buildserver
      
  4. Place the required database drivers into the lib/jdbc sub directory subdirectory of the newly created TeamCity Data directoryDirectory 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:

      Code Block
      maintainDB.[cmd|sh] restore -A <absolute path to the newly created TeamCity Data Directory> -F <path to the TeamCity backup file> -T <config/database.properties>

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

      Code Block
      maintainDB.[cmd|sh] restore -A <absolute path to the newly created TeamCity Data Directory> -F <path to the TeamCity backup file> -T <absolute path to the database.properties file of the target 
    database>
    1. database on the file system outside data dir>
    2. To restore the data into the same database the backup was created from:

      Code Block
      maintainDB.[cmd|sh] restore -A <absolute path to the newly created TeamCity Data Directory> -F <path to the TeamCity backup file>
    3.  To restore the backup into the internal database:

      - TeamCity 10.0.5 and later

      Code Block
      maintainDB.[cmd|sh] restore -A <absolute path to the newly created TeamCity Data Directory> -I -F <path to the TeamCity backup file>

      - prior to TeamCity 10.0.5: 

      Code Block
      maintainDB.[cmd|sh] restore -A <absolute path to the newly created TeamCity Data Directory> -F <path to the TeamCity backup file> -T <absolute path to the database.properties file of the target database on the file system outside data dir>
  6. If the process completes successfully, copy over <TeamCity Data Directory>/system/artifacts from the old directory.

 

Restore 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 should must point to the temporary  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.

Info

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

...

  1. Create and configure the database, placing the database.properties file (this is a temporary file for the purposes of restore) into any directory other than 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. Use the restore command (The -T argument should must point to the temporary  database.properties file created in step 1):

    Code Block
    maintainDB.[cmd|sh] restore -A <absolute path to the newly created TeamCity Data Directory> -F <path to the TeamCity backup file> -T <absolute<path path to the database.properties file of the target database> -D
  5. See the maintainDB utility console output. You may have to copy the database.properties file manually if requested.

...