Citrix VAD Database migration

Citrix Virtual Apps and Desktops contains of 3 databases, Logging, Monitoring and site database. Logging and Monitoring can be moved with GUI(Studio) but Site need to be done by PowerShell. After some struggling and no good documentation or guides I finally found a solution that a want to share.

Logging and Monitoring

As mention this databases can be moved within Studio. Do it like this:

  1. Stopp database logging and monitoring
    1. Stop Logging with this PowerShell command: “Set-LogSite -State Disabled”
    2. Stop monitoring with this PowerShell command: “Set-MonitorConfiguration -DataCollectionEnabled $False”
  2. Take full SQL backup of both database
  3. Logg into Studio and click “Configuration”. Mark Logging or Monitoring database and choose “Change Database” on right side. Repeat this operation for both databases.

4. After both database i created on new SQL you need to restore backup to get old data. If you dont need old data can you skip this step.

Site Database

This database need to be moved with PowerShell. Start on first DDC and complete this before start on second DDC.

  1. Backup old database and restore on new SQL. Remember to control that ACL on database is correct. (Same as old server)
  2. First step is to remove DBConnection on DDC with following PowerShell command:
## Load the Citrix snap-ins
asnp Citrix.*

## Disable configuration logging for the XD site:
Set-LogSite -State Disabled

## Clear the current DDC database connections
Set-ConfigDBConnection -DBConnection $null
Set-AppLibDBConnection -DBConnection $null    #7.8 and newer
Set-OrchDBConnection -DBConnection $null      #7.11 and newer
Set-TrustDBConnection -DBConnection $null     #7.11 and newer
Set-AcctDBConnection -DBConnection $null
Set-AnalyticsDBConnection -DBConnection $null # 7.6 and newer
Set-HypDBConnection -DBConnection $null
Set-ProvDBConnection -DBConnection $null
Set-BrokerDBConnection -DBConnection $null
Set-EnvTestDBConnection -DBConnection $null
Set-SfDBConnection -DBConnection $null
Set-MonitorDBConnection -DataStore Monitor -DBConnection $null   #Monitoring Database
Set-MonitorDBConnection -DBConnection $null                      #Site Database
Set-LogDBConnection -DataStore Logging -DBConnection $null       #Logging Database
Set-LogDBConnection -DBConnection $null                          #Site Database
Set-AdminDBConnection -DBConnection $null -force

2. Next you need to restart all Citrix services. This can be done with PowerShell:

Get-Service Citrix* | Stop-Service -Force
Get-Service Citrix* | Start-Service

3. Before add new connection, control that DBConnection is clean. Output of this command should be “Empty filed”:

Get-AnalyticsDBConnection              #  for 7.6 and newer
Get-AppLibDBConnection                 #  for 7.8 and newer
Get-OrchDBConnection                   #  for 7.11 and newer
Get-TrustDBConnection                  #  for 7.11 and newer

4. To set new DBConnection value, run following commands. Remember to correct db Servername and DBName before you run.

$SiteDBName = "CTX_Site"
$LogDBName = "CTX_Log"
$MonitorDBName = "CTX_Mon"
$csSite = "Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True"
$csLogging = "Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True"
$csMonitoring = "Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True"

Set-AdminDBConnection -DBConnection $csSite
Set-ConfigDBConnection -DBConnection $csSite
Set-AcctDBConnection -DBConnection $csSite
Set-AnalyticsDBConnection -DBConnection $csSite # 7.6 and newer
Set-HypDBConnection -DBConnection $csSite 
Set-ProvDBConnection -DBConnection $csSite
Set-AppLibDBConnection –DBConnection $csSite # 7.8 and newer
Set-OrchDBConnection –DBConnection $csSite # 7.11 and newer
Set-TrustDBConnection –DBConnection $csSite # 7.11 and newer
Set-BrokerDBConnection -DBConnection $csSite
Set-EnvTestDBConnection -DBConnection $csSite
Set-SfDBConnection -DBConnection $csSite
Set-LogDBConnection -DBConnection $csSite
Set-LogDBConnection -DataStore Logging -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-LogDBConnection -DBConnection $csSite
Set-LogDBConnection -DataStore Logging -DBConnection $csLogging
Set-MonitorDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DataStore Monitor -DBConnection $null
Set-MonitorDBConnection -DBConnection $null
Set-MonitorDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DataStore Monitor -DBConnection $csMonitoring
Set-LogSite -State Enabled

5. Finally run the check again to control that all field has value. (Same as point 3) Also control Studio that is starts normal and show that Site database also has been moved.

Another good article that cover some other detailed can be read here.

Leave a Reply