View Source

TeamCity allows administrator to restore previously [backed up data|Creating Backup via maintainDB command-line tool] using the {{maintainDB}} command line utility.

{note}Please note that restoration of the backup created with TeamCity versions earlier then 6.0 can only be performed with *the same TeamCity version* which created the backup.
Backups created with TeamCity 6.0 or more recent versions can be restored by the same or more recent TeamCity versions.{note}

To restore TeamCity server from previously saved backup file, ensure TeamCity server is not running and target [TeamCity Data Directory] and database are present, but empty.
Then use {{maintainDB}} utility which is located in the <TeamCity Home>/bin directory. That is only available in TeamCity .tar.gz and .exe distributions.
Use the {{restore}} command:

{code}maintainDB[cmd|sh] restore -F <full file name of TeamCity backup file> -A <path to TeamCity Data Directory> -T <path to the file of the target database>{code}
\-A argument can be omitted if you have [TEAMCITY_DATA_PATH|TeamCity Data Directory] environment variable set.
\-T argument can be omitted if you want to restore the data into the same database the backup was created from. For restoration into internal database, use {{.BuildServer\config\}} file available as the default content of the TeamCity Data Directory.

By default, maintainDB looks for the specified backup file in the default backup directory: {{<TeamCity Data Directory>/backup}}. If the file is not found, the process will be aborted with an error. To override this setting, you can specify the _absolute path_ to the desired backup file in a custom directory with the {{\-A}} option.

By default, if no other option that {{\-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 corresponding options of the {{maintainDB}} utility: {{\-C}}, {{\-D}}, {{\-L}}, and {{\-P}}.
To get the reference for the available options of the {{maintainDB}}, run the utility without any command or option.

* \-C or \--include-config --- includes build configurations settings
* \-D or \--include-database --- includes database
* \-L or \--include-build-logs --- includes build logs
* \-P or \--include-personal-changes --- includes personal changes

h3. Restoring Data from Backup to Another Database

You can restore data into another empty database. Types of the source (from which the data is backed up) and target (to which the data will be restored) databases don't matter. For instance, you can restore data from a HSQL database to a MySQL database, as well as restore a backup of MySQL database to a new MySQL database.
Essentially, restoring data from a backup file to another database is a migration process.

*To restore database data to another database*:
# If you need to preserve properties of the target database, create new {{}} file from a template, which corresponds to the type of the target database, or copy the existing one to a temporary directory.
# Run the maintainDB utility with {{restore}} command and \-T option:
maintainDB restore -F <backup file> -T <absolute path to the file of the target database>
All backed up scopes will be restored and the database will be restored to a new one.

To restore database only, use the {{\-D}} option.

{color:#003366}{*}See also:*{color}
*Administrator's Guide*: [Creating Backup via maintainDB command-line tool|Creating Backup via maintainDB command-line tool]