Since TeamCity 5.0, you can back up server data, restore it, and migrate between different databases using single maintainDB.bat|sh utility. For the data backup, TeamCity also provides web UI part, in the Backup Data of TeamCity web UI.
maintainDB utility is located in the <TeamCity Home>/bin directory.
note
Please note that to restore backup you need the same TeamCity version that the backup is made with, so make sure you store TeamCity installation package together with the backup.
To get short reference for all available maintainDB options, run maintainDB from command line with no parameters.
This section covers:
Backing up Data
TeamCity allows backing up the following data:
Server settings and configurations, which includes all server settings, properties, and project and build configuration settings
Database
Build logs
Personal changes
By default, if you run maintainDB utility with no optional parameters, build logs and personal changes will be omitted in the backup.
The default directory for the backup files is the < > \backup.
note
If not specified otherwise with the -A option, TeamCity will read the TeamCity Data Directory path from the TEAMCITY_DATA_PATH environment variable, or the default path ($HOME\.Buildserver) will be used.
Default format of the backup file name is TeamCity_Backup_<timestamp>.zip; the <timestamp> suffix is added in the 'YYYYMMDD_HHMMSS' format.
Performing TeamCity Data Backup with maintainDB Utility
note
Before starting data backup you need to stop TeamCity server.
To create data backup file, from the command line start maintainDB utility with the backup command:
maintainDB.[cmd|sh] backup
To specify type of data to include in the backup file, use the following options:
-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
Specifying different combinations of the above options, you can control the content of the backup file. For example, to create backup with all supported types of data, run
maintainDB backup -C -D -L -P
maintainDB Usage Examples for Data Backup
To create backup file with custom name, run maintainDB with -F or --backup-file option and specify desired backup file name without extension:
To create backup file in the custom directory, run maintainDB with -A option:
maintainDB backup -A <absolute path to the custom backup directory> or maintainDB backup --data-dir <absolute path to the custom backup directory>
Creating TeamCity Data Backup via Web UI
TeamCity allows creating a backup of TeamCity data via the Web UI. To create new backup file, navigate to the Backup Data page of the Administration section, specify backup parameters and start backup process.
The backup file, by default, will be created in the < > \backup directory.