...
Dump specific tables from source TeamCity database
Code Block |
---|
|
mysqldump --no-tablespaces -u teamcity -p teamcity ids_group \
ids_group_entity_id \
project \
project_mapping \
user_blocks \
user_build_parameters \
user_build_types_order \
usergroup_notification_data \
usergroup_notification_events \
usergroup_roles \
usergroups \
usergroup_subgroups \
usergroup_users \
usergroup_watch_type \
user_notification_data \
user_notification_events \
user_projects_visibility \
user_property \
user_roles \
users \
user_watch_type \
vcs_username > teamcity.sql |
- Copy
/<source-teamcity-data-dir>/config/roles-config.xml
Pack dump and configuration fail into archive
Code Block |
---|
|
zip -r users-groups-roles.zip teamcity.sql roles-config.xml |
- Copy archive to target TeamCity instance
<source-teamcity-host>
Unpack archive
Code Block |
---|
|
unzip users-groups-roles.zip |
- Place
roles-config.xml
to /<target-teamcity-data-dir>/config/roles-config.xml
Restore specific tables (TeamCity and/or DB service stop is not required)
Code Block |
---|
|
mysql -u teamcity -p teamcity < teamcity.sql |
- Restart TC (restart is required to re-read some DB data which is not updated on-the-fly).
Stop queue
Code Block |
---|
|
curl -s \
-u "<tc_username>:<tc_password>" \
-X POST \
"https://<tc_url>/queueStartStop.html?stateChangeReason=TeamCity+daily+maintenance&newQueueState=false" |
Wait for non-composite running builds to finish
Code Block |
---|
|
while true; do
runningBuildsCount="$(curl -s \
-u "<tc_username>:<tc_password>" \
-X GET \
"https://<tc_url>/app/rest/builds/?locator=state:running,composite:false" | \
xmllint --format \
--xpath "string(/*[local-name()='builds']/@count)" -)"
if [ "$runningBuildsCount" -gt 0 ]; then
echo " $(timestamp) Running builds left: ${runningBuildsCount}"
sleep 60
else
break
fi
done |
Restart server
Code Block |
---|
|
curl -s \
-u "<tc_username>:<tc_password>" \
-X POST \
"https://<tc_url>/admin/serverRestart.html?start=1" 1>/dev/null 2>&1
sleep 10 |
Wait for TeamCity to boot
Code Block |
---|
|
while true; do
returnCode="$(curl -s \
-I \
-u "<tc_username>:<tc_password>" \
-o /dev/null \
-w "%{http_code}" \
-X GET \
"https://<tc_url>/app/rest/server")"
if [ "${returnCode}" != "200" ]; then
echo " $(timestamp) Current TeamCity HTTP status: ${runningBuildsCount}"
sleep 60
else
break
fi
done |
Resume TeamCity queue
Code Block |
---|
|
curl -s \
-u "<tc_username>:<tc_password>" \
-X POST \
"https://<tc_url>/queueStartStop.html?stateChangeReason=&newQueueState=true" |
Backup
TeamCity server has embedded backup tool which can backup database, project files and settings and build logs and artifacts.
Backup can be done in two ways:
- Via UI: https://ci.ignite.apache.org/admin/admin.html?item=backup
Via REST API:
(optional) Remove old backups
Code Block |
---|
|
find "<teamcity-data_dir>/backup/" -type f -ctime +<days> -exec rm -rfv {} \; | sed -r 's|^| - |' |
Initiate backup
Code Block |
---|
|
curl -s \
-u "<tc_username>:<tc_password>" \
-X POST \
"https://<tc_url>/app/rest/server/backup?includeConfigs=true&includeBuildLogs=false&fileName=<tc_backup_name>" |
...
Travis CI
...
Backlog issues
- TC: Introduce automated instructions for preparing Linux and Windows agents.
- TC: Remove obsolete secret tokens.
- TC: Introduce Kotlin DSL based settings (instead of XML).