Citrix

How to migrate Citrix Xenapp v7.x database to another SQL server

By Nik

March 26, 2023

Recently we had to migrate the Citrix XenApp v7.x database from SQL Server 2012 to SQL Server 2022. Here’s the tutorial on how to do this if you’re using three Citrix data stores or databases (Site, Monitoring; Logging).

  1. First of all and most important step!

2. Get the Connection Strings for each DB.

Run the following commands in Powershell (elevated mode) to get the DB connection strings for each of the three data stores:

Run the Asnp Citrix* command to load the Citrix snap-in commandlets.

Site Database: Get-BrokerDBConnection

Logging Database: Get-LogDataStore

Monitoring Database: Get-MonitorDataStore

Write down the Connection Strings you got with the above commands (example): ConnectionString: “Server=Contoso\CITRIX;Initial Catalog=Citrix_Xenapp7_Site;Integrated Security=True”

We’ll need this to create Powershell variables that will be used to connect DDCs to a new DB server.

3. Detach all DB connections from each Delivery Controller in the farm by running the following commands in Powershell (elevated mode):

Set-AcctDBConnection -DBConnection $null Set-AnalyticsDBConnection -DBConnection $null Set-AppLibDBConnection -DBConnection $null Set-BrokerDBConnection -DBConnection $null Set-ConfigDBConnection -DBConnection $null Set-EnvTestDBConnection -DBConnection $null Set-HypDBConnection -DBConnection $null Set-OrchDBConnection -DBConnection $null Set-ProvDBConnection -DBConnection $null Set-SfDBConnection -DBConnection $null Set-TrustDBConnection -DBConnection $null Set-MonitorDBConnection -Datastore Monitor -DBConnection $null Set-MonitorDBConnection -DBConnection $null Set-LogDBConnection -Datastore Logging -DBConnection $null Set-LogDBConnection -DBConnection $null Set-AdminDBConnection -DBConnection $null

Run each of these commands one by one. That’s a better approach in case you run into an error with any of these commands.

If you run into an error that says: The operation could not be performed because of a configuration logging error. – Run the command again with the -force switch and it should be completed successfully.

4. Move the Databases to the new SQL Server.

You might need help from a DB admin since you’ll have to create logins for the DDCs and give required permissions as was the case on the old DB server.

5. Run Powershell in elevated mode and create connection string variables for three Citrix Datastores.

# Site DB $cs = “Server=Contoso\CITRIX;Initial Catalog=CitrixXenapp7_Site;Integrated Security=True” # Logging DB $csl = “Server=Contoso\CITRIX;Initial Catalog=CitrixXenapp7_Logging;Integrated Security=True” # Monitor DB $csm = “Server=Contoso\CITRIX;Initial Catalog=CitrixXenapp7_Monitoring;Integrated Security=True”

Replace bold parts with your SQL Server name and Instance name, along with the Initial Catalog name or Datastore name that we got in step 2.

Now run the three commands above (italic font) to set variables for Site, Logging, and Monitoring datastores.

6. Connect the Citrix DDCs to the new SQL server by running each of the following commands:

Set-AdminDBConnection -DBConnection $cs Set-AcctDBConnection -DBConnection $cs Set-AnalyticsDBConnection -DBConnection $cs Set-AppLibDBConnection -DBConnection $cs Set-BrokerDBConnection -DBConnection $cs Set-ConfigDBConnection -DBConnection $cs Set-EnvTestDBConnection -DBConnection $cs Set-HypDBConnection -DBConnection $cs Set-OrchDBConnection -DBConnection $cs Set-ProvDBConnection -DBConnection $cs Set-SfDBConnection -DBConnection $cs Set-TrustDBConnection -DBConnection $cs Set-LogDBConnection -DBConnection $cs Set-LogDBConnection -Datastore Logging -DBConnection $null Set-LogDBConnection -Datastore Logging -DBConnection $csl Set-MonitorDBConnection -DBConnection $cs Set-MonitorDBConnection -Datastore Monitor -DBConnection $null Set-MonitorDBConnection -Datastore Monitor -DBConnection $csm

Once done, restart each DDC and try to run the Studio to check that everything is working properly.

In the left pane of the Citrix studio administration console, select Configuration to confirm that each of the three data stores is now connected to the new SQL Server.

All the connection strings that we added in step 6. could be found in Windows Registry on DDC at the following path:

HKLM\SOFTWARE\Citrix\XDservices and HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\DesktopServer\DataStore\Connections\Controller

Comments are welcome!