Migrate Citrix Virtual Apps and Desktop databases to a new SQL server

book

Article ID: CTX558936

calendar_today

Updated On:

Description

Please follow these steps.
1. Close all instances of Citrix Studio. Any configuration changes (even through PowerShell) must be stopped while following the steps (You can power down DDCs to be extra cautious).
Take VM snapshot or take backup of all Delivery Controllers.
2. Take full backup of Site, Monitor and Logging databases.
3. Restore Site, Monitor and Logging databases from backup to the new SQL server.
4. Add databases to Cluster, Always-on or Mirror (if applicable).
5. Create logons for the Delivery Controllers on new SQL server(s) and permission should like this.
-- In this example Databases are Citrix1912-LTSRSiteCitrix1912-LTSRLogging and Citrix1912-LTSRMonitoring

image.png

image.png

image.png

6. Power on all Delivery Controllers and note down DB connection Strings for Broker service and Logging and Monitor datastore.
- Open Administrator PowerShell on one Delivery Controller and execute following commands
-- Add-PSSnapin Citrix*
-- Get-BrokerDBConnection
-- Get-LogDataStore
-- Get-MonitorDataStore


image.png

7. Make sure there is no connectivity issue from Delivery Controllers to new SQL Server / Cluster / Always-on Listener.
-- You can create a file with .udl extension, open it on the Delivery Controller and test connection as follows.

image.png

8. Prepare DB Connection strings to set though PowerShell. If you are using specific SQL instance and non-default SQL port connection string will be like this.
$Site = "Server=<NewSQLServer\InstanceName,CustomPortNumber>;Initial Catalog=<Site Database name>;Integrated Security=True"
$Logging = "Server=<NewSQLServer\InstanceName,CustomPortNumber>;Initial Catalog=<Logging database name>;Integrated Security=True"
$Monitor = "Server=<NewSQLServer\InstanceName,CustomPortNumber>;Initial Catalog=<Monitor database name>;Integrated Security=True"


For default instance and port connection strings will be like this.
$Site = "Server=<NewSQLServer>;Initial Catalog=<Site Database name>;Integrated Security=True"
$Logging = "Server=<NewSQLServer>;Initial Catalog=<Logging database name>;Integrated Security=True"
$Monitor = "Server=<NewSQLServer>;Initial Catalog=<Monitor database name>;Integrated Security=True"

Example:
$Site = "Server=MYSQLSERVER.DOMAIN.LOCAL;Initial Catalog=MySiteDatabase;Integrated Security=True"


9. Download the script attached and update line 85 (Step 10), 103 (Step 11), 108 (Step 12) and execute sections as instructed in the script.
10. Restart Delivery Controllers, open Studio.
11. Check VDA registration and launch.

Please note that if the change is linked to a product update, there was a VUS service introduced as a FMA service operating on the Delivery Controller since release 2411.
Upgrading the Site from version 2402 to 2507 is taken as an example. When some of the Delivery Controllers in the Site had been upgraded to 2507 and the Site upgrade was performed, the database schema was upgraded to the corresponding version, and all FMA services on those Delivery Controllers were configured successfully, including the VUS service.
However, the remaining older version of Delivery Controllers had not yet installed the VUS service because they had not been upgraded to the 2507 release yet.
Therefore, after upgrading the remaining Delivery Controllers, it is required to close and reopen Site Manager. Site Manager may then prompt the Citrix administrator to perform an additional Site upgrade to register all the Delivery Controller’s services to the site.
This is also documented here: https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/upgrade-migrate/upgrade#step-9-upgrade-remaining-delivery-controllers 

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Issue/Introduction

Migrate Citrix Virtual Apps and Desktop databases to a new SQL server

Attachments

Database Migration Script.zip get_app