This article describes how to move an existing XenDesktop database from one SQL server to another.
Complete the following procedure to move an existing XenDesktop database from one SQL server to another:
On each Desktop Delivery Controller (DDC) in the site, start PowerShell using the Run as administrator option.
Copy and paste the following code into the PowerShell window:
asnp Citrix.* Set-ConfigDBConnection -DBConnection $null Set-AcctDBConnection -DBConnection $null Set-HypDBConnection -DBConnection $null Set-ProvDBConnection -DBConnection $null Set-PvsVmDBConnection -DBConnection $null Set-BrokerDBConnection -DBConnection $null
Leave the PowerShell window open for Step 4.
Back up and restore the database:
Note: Do a get-configDBConnection beforehand to get the name of the SQL database, because it may not always be called CitrixXenDesktopDB
For SQLExpress installations, run the following command at the cmd prompt on the DDC that contains the database:
sqlcmd -S LOCALHOST\SQLEXPRESS -q "Backup Database CitrixXenDesktopDB to disk = 'database-backup-location-directory-path' (example: C:\backup\test.bak)
For more information regarding backing up and restoring databases, see http://msdn.microsoft.com/en-us/library/ms190436.aspx.
Create Machine logins for all DDCs on the new database server:
Start SQL Server Management Studio or SQLCMD on the SQL server housing the restored database.
XenDesktop 5.x uses machine accounts of the DDC servers to access the database directly. Create machine account logins for each of the DDCs in the site.
Each of the machine accounts should have their Database role membership set to the following roles:
ADIdentitySchema_ROLE
chr_Broker
chr_Controller
ConfigurationSchema_ROLE
DesktopUpdateManagerSchema_ROLE
HostingUnitServiceSchema_ROLE
MachinePersonalitySchema_ROLE
At each DDC, copy and paste the following lines into the open PowerShell window where <dbserver> is the name of your SQL server and <dbname> is the name of the XenDesktop database:
Set-ConfigDBConnection -DBConnection "Server= dbserver;Initial Catalog= dbname;Trusted_Connection=True" Set-AcctDBConnection -DBConnection "Server= dbserver;Initial Catalog= dbname;Trusted_Connection=True" Set-HypDBConnection -DBConnection "Server= dbserver;Initial Catalog= dbname;Trusted_Connection=True" Set-ProvDBConnection -DBConnection "Server= dbserver;Initial Catalog= dbname;Trusted_Connection=True" Set-PvsVmDBConnection -DBConnection "Server= dbserver;Initial Catalog= dbname;Trusted_Connection=True" Set-BrokerDBConnection -DBConnection "Server= dbserver;Initial Catalog= dbname;Trusted_Connection=True"
Note: If you are not using the default SQL Server instance, the Server= dbserver element should be specified as Server= dbserver\instancename. If you do not specify the instance name, you might see a message of Failed rather than OK when running the various preceding commands.
Note: It is important to verify that all of the Set-<service>DBConnection commands mentioned have returned a result of OK. If a result other than OK is returned for any of these commands, it might be necessary to enable logging or tracing to determine the cause of the connection failure.
If any Virtual Desktop Agents were running when the DDC services were shut down in Step 1, then it could take up to 10 minutes before the Virtual Desktop Agents re-register. No other action is necessary.
Note: The preceding procedure and PowerShell commands must be run on every DDC in the Farm. If not, the Desktop Studio will not open.
For XenDesktop 7.x - How to Migrate XenDesktop Database to New SQL Server
CTX128075 - XDDBDiag for XenDesktop
CTX127254 - XenDesktop 5.6 SDK Cmdlet Help
CTX114501 – Supported Databases for Citrix Products