Tuesday 22 August 2017

Cloning Your TFS Server Part 02 – Prepare Restored Databases

You have to make sure you are not corrupting your current TFS instance that is up and running, while you are cloning a  TFS instance. For this you need to prepare the restored databases of the TFS, in new hardware, before configuring the cloned Application Tier of TFS. In the “Cloning Your TFS Server Part 01 – Backing Up and Restoring Databases” how to back up and restore TFS database was discussed in detail. Let’s look at each of the preparation steps required in order to guarantee both current TS instance and cloned instance can coexist in the same network.

SharePoint

If you have SharePoint with your TFS then execute below commands, to redirect SharePoint products to  new content databases restored. You have to do this in the SharePoint foundation machine you have setup in new hardware. Change directory to Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\bin and the execute the commands.

stsadm.exe –o addcontentdb –url http://SharePointFoundationServerName/sites -databasename WSS_Content -databaseserver SQLServerName

stsadm.exe -o addpermissionpolicy -url http://SharePointFoundationServerName -userlogin Domain\UserName -permissionlevel "full control"

Server IDs

This step is mandatory to prevent risk of corruption of your current TFS instance and Cloned instance if both are live together. Corruption could happen if they are pointing to same SharePoint or Report Server. Open a command prompt as an administrator and change the directory to Team Foundation server tools folder. in the new Application Tier (AT). It can be Drive:\%programfiles%\Microsoft Team Foundation Server 12.0\Tools if the TFS instance is TFS 2013. For TFS 2015 it is Drive:\%programfiles%\Microsoft Team Foundation Server 14.0\Tools.image

Execute the command below to prepare for TFS clone. This will remove information about scheduled backups, SharePoint, and reporting resources from a Team Foundation Server (TFS) deployment. You must run this command before configuring AT of your cloned TFS. For more information visit here.

TFSConfig PrepareClone /SQLInstance:ServerName /DatabaseName:TFSConfigurationDatabaseName /notificationURL:ApplicationTierURL

When above command executed you might run into error below if you have not restored the TFS_Analysis database.

TF246083: The configuration of Team Foundation Server is not valid. You must remap the databases in order to fix the configuration. The following error was received from the server: TF400673: Unable to find any compatible SQL Analysis Services database within the specified instance.'2' hosts have been given updated connection strings.image

With TFS_Analysis database restore in the new database server prepare clone command executes successfully.image

If you have configure Lab management for current TFS instance you will see a warning as shown above. As instructed execute TfsConfig.exe lab /delete /collectionName:collectionName to clear all lab assets from the clone, once the configuration of Application Tier of the cloned TFS instance is completed. This further will be discussed in the next article.

After prepare clone execute the ChangeServerID command to change the server GUIDs associated with the TFS databases.

TFSConfig ChangeServerID /SQLInstance:ServerName /DatabaseName:ConfigurationDatabaseName

Once the command executed it will prompt you to confirm Application Tier is not configured as this command should only be executed in a scenario where Application Tier of TFS is not configured and databases just restored.image

All database IDs will be changed with the command.image

Next execute RemapDBs command to redirect TFS to its databases in new hardware. This is not mandatory as you can see previous command already remapped the databases as shown in above screenshot. But you can execute the command to make sure it is properly mapped.

TFSConfig RemapDBs /DatabaseName:ServerName;ConfigurationDatabaseName /SQLInstances:ServerName1,ServerName2 [/AnalysisInstance:ServerName] [/AnalysisDatabaseName:DatabaseName] [/preview] [/continue] [/usesqlalwayson]image

You should get the message that the current configuration is valid as shown above.

With the above steps the TFS databases in new hardware is prepared and ready for configuring as a cloned instance of current TFS. These two instances can coexist in the same network after the clone is configured. In the next article we will have a look at how to configure the cloned instance.

3 comments:

Unknown said...

Well. I have a problem while doing this for tfs 2017.
"TFSConfig PrepareClone" command seem to have been removed from tfs 2017.

Here they say: "Command availability: TFS 2015 and TFS 2013"
https://docs.microsoft.com/en-us/vsts/tfs-server/command-line/tfsconfig-cmd?view=tfs-2017

And I can't find any substitute. Any ideas?

Chaminda Chandrasekara said...

You can omit the prepareclone and continue from the rest of the commands. I have written a post on TFS 2018, explaining this. https://chamindac.blogspot.com/2018/02/clone-2018.html

Unknown said...

Ok thank you. I'll look at that.

Popular Posts