fd Blog

Daniel Hilgarth on software development

Move TeamCity Installation to New Server

On the old server

Create a backup

  1. Log into TeamCity with an account with administrative rights.
  2. Navigate to Administration > Server Administration\Backup
  3. On the “Run Backup” tab, change the “Backup scope” to “Custom” and select everything.
  4. Stop TeamCity

     sudo service teamcity stop
    
  5. Transfer the data directory to the new server:

     scp -P 22 -r /opt/jetbrains/TeamCity/.BuildServer <user>@<new-server>:/location/on/new/server
    

    This will also transfer the backup file.

On the new server

Setup TeamCity

As per the first part of this post. Additionally, follow the steps to create the MySQL database.

Prepare for backup restore

sudo mkdir /opt/jetbrains/TeamCity/.BuildServer/
sudo mkdir /opt/jetbrains/TeamCity/.BuildServer/lib/
sudo mkdir /opt/jetbrains/TeamCity/.BuildServer/lib/jdbc/
sudo mv /location/on/new/server/.BuildServer/lib/jdbc/mysql-connector-java-5.1.31-bin.jar /opt/jetbrains/TeamCity/.BuildServer/lib/jdbc/
sudo chown teamcity:teamcity /opt/jetbrains/TeamCity/.BuildServer/lib/jdbc/mysql-connector-java-5.1.31-bin.jar

Restore the backup

sudo -i
cd /opt/jetbrains/TeamCity/bin
./maintainDB restore -F /location/on/new/server/.BuildServer/backup/<backup-file> -A /opt/jetbrains/TeamCity/.BuildServer -T /location/on/new/server/.BuildServer/config/database.properties
exit
sudo rm -rf /opt/jetbrains/TeamCity/.BuildServer/system/artifacts
sudo cp -r /location/on/new/server/.BuildServer/system/artifacts /opt/jetbrains/TeamCity/.BuildServer/system/
sudo cp -r /location/on/new/server/.BuildServer/plugins /opt/jetbrains/TeamCity/.BuildServer
sudo cp -r /location/on/new/server/.BuildServer/system/pluginData /opt/jetbrains/TeamCity/.BuildServer/system
sudo chown -R teamcity:teamcity /opt/jetbrains/TeamCity

Start TeamCity

sudo service teamcity start

References

http://blogs.endjin.com/2013/07/a-step-by-step-guide-to-migrating-a-teamcity-instance-from-one-server-to-another/

Comments