Monday, 21 August 2017

Cloning Your TFS Server Part 01 – Backing Up and Restoring Databases

You might want to clone your TFS instance if you are doing a hardware move upgrade. There can be other situations such as you need to move one of your projects to VSTS (Team Services) using high fidelity database import, without migrating other projects in the same collection. If you prefer to keep your current TFS untouched while trying to create an isolated collection for a single project, you might want to clone and create an instance of your TFS. There can be several other experimental reasons you may have to clone a TFS instance.


Let’s look at backup options we have.

You can backup TFS after stopping all services and taking manual backups via SQL Management Studio. If you want to keep your TFS running while you take backup, you can use the TFS administration console backup scheduler and trigger a manual backup. First create scheduled backup with manual backup option selected. Then take a backup by manually triggering a full backup.image

But if you are taking a backup without stopping TFS services, make sure you have no other backup plans running using SQL server backup devices etc. This is because your backups to be restored should be in time sync etc and it will be done using trn files added to backup set. If any other SQL trn (transaction log) backups happen during the long running TFS backup process you may encounter issues in restoring. make sure to add a report key encryption password and remember it for restoration, in different hardware. The learnings here are also worth having a consideration.

Backup set will not include the Tfs_Analysis backup. To take the analysis database backup connect to Analysis Services via SQL Management Studio and take the backup manually. This database should be rebuilt with the warehouse once the cloning of TFS completed. But this is required to be restored to allow running commands such as prepare clone, which will be explained in next article.image

Provide path and name of the backup file with extension .abf and click OK.image

To Restore

First setup your target machine with same SQL server version of your current TFS database server. Higher version of SQL also works fine. To find out the version and edition of your TFS database SQL server execute below commands in a new query.

SELECT @@VERSION

SELECT SERVERPROPERTY('edition')00

Setup the TFS version (exactly current TFS version you have in your current TFS server) in the target clone server. You can find the Current TFS version in Admin console of your current TFS server AT.01

Once the same version is installed, do not configure anything, close the wizard that appears.03

Go to Scheduled Backups and click on Restore Databases. This process will only restore the databases in SQL server, but will not configure a TFS server clone.04

In the restore wizard you have to set the backup path where your backup set is available.05

In the next step select all databases. and provide the new Database server name (Current TFS database server name appears here, do make sure to change it to new one before proceeding).06

In the next step provide the password you have used when creating backup of the reporting services key.07

You can review the settings and then run the readiness checks.08

09

You might get the above shown error if you have your new SQL server reporting services configured in native mode. Go to the SQL reporting services and change the database name to something like ReportServer1. 10

11

After configuring the report server with different database name remove the ReportServer and ReportServerTemp databases from SQL server.12

With this your readiness checks should pass.13

Click o Restore to restore the databases. This will take considerable amount of time depending on your TFS databases size.14

Restore operation completed with warning on failure to restore the reporting services key.15

image

Out of below issues we have to only worry about the reporting services key as we are cloning our TFS environment.

TF400980: Failed to restore the Reporting Services encryption key. You can try using RSKEYMGMT command to restore the encryption key
 
TF401010: The backup path changed since Scheduled Backups were configured.  This may cause future backups to fail.  Rerun the Scheduled Backups wizard to update the settings to the new path.
 
You may need to purge the version control file cache on all TFS ATs and all TFS proxy servers that service the TFS instance prior to putting the TPC back online. For more information, see this KB article
http://support.microsoft.com/?kbid=2025763

To get the reporting services working with the restored report services DBs go to change databases in Reporting Services Configuration Manager, and change database. Select the option of use existing database and proceed.image

Select the restored ReportServer database. Then proceed with the wizard to set the databases to restored ReportServer and ReportServerTemp.image

To restore the encryption key go to Encryption Keys and click on Restore.image

Provide the encryption key that is backed up earlier, and provide the password. image

Encryption key should be restored successfully.image

You can safely remove the temporary report server databases created earlier named ReportServer1 and ReportServer1Temp.

You should be able to see your report services now containing the TFS reporting server database information and details of each of the collections.image

image

As the last step restore the analysis database. In analysis services of new server click restore in databases menu.image

Select the backup taken and provide TFS_Analysis as the name of the database to restore. Make sure to copy backup to a local drive to avoid access denied errors when trying to restore.image

In the next post we will look at how to prepare restored databases for cloning the TFS instance.

3 comments:

Anonymous said...

THANK YOU!

Kristján Halldórsson said...

Can I follow this same procedure for TFS 2017 (update 3.1) ?

To simplify things I don't have sharepoint or reports set up.

Chaminda Chandrasekara said...

Yes you can

Popular Posts