Skip to main content

How to Restore a XenDesktop 5 Database on a SQL 2008 Server


This article contains information about restoring a XenDesktop 5 database on a SQL 2008 Server


It is assumed that the administrator has basic knowledge for SQL administration or has appropriate resources to assist with the execution of the SQL statement command.


When using Microsoft SQL Server, consult the Database Server product documentation for scheduling automated backups of the Data Store. In most cases, daily backup is sufficient to prevent loss of farm data.

In this scenario, it is expected that the Citrix Data Store is unavailable until the procedure is complete. Therefore, complete all the steps in the following procedure within the same change window.


  • It is strongly recommended that no administrative changes be attempted until the Database is back online and verified.
  • All Management Consoles should be closed.

Review throttling and idle pool settings as soon as you restore the DB to mitigate the possibility of boot storms

The following environmental data is used as an example:


  • Restore the most recent database backup onto the target server.

Refer to the Copying Databases with Backup and Restore web page of Microsoft msdn library for more information

  • Verify that all DDCs have valid logins for their machine account in the form DomainName\Computername$ on the database server. If verified, move to Step 3.
  • To create machine logins for all DDCs on the database server, complete the following procedure:
  • Start SQL Server Management Studio or SQLCMD,
  • Run the CREATE LOGIN [DOMAIN\MACHINE$] FROM WINDOWS query, as displayed in the following screen shot:
Note: Use upper-case for the Domain and Computer Name
  • Each DDC Machine Login should have a corresponding user account under the restored Database. Locate these accounts and verify that their Database role membership is set to the following role, as displayed in the screen shot:
  • ADIdentitySchema_ROLE
  • chr_Broker
  • chr_Controller
  • ConfigurationSchema_ROLE
  • DesktopUpdateManagerSchema_ROLE
  • HostingUnitServiceSchema_ROLE
  • MachinePersonalitySchema_ROLE
  •  Redirect DDCs to the new database:
  • At each DDC, open a PowerShell window and run the following commands where <dbserver> is the name of your SQL server, which is the instance if defined and <dbname> is the name of the XenDesktop database. This process loads the Citrix PowerShell Snap-in, clear the database connection and then configure the correct connection for each service:

    Add-PSSnapin 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 Set-ConfigDBConnection -DBConnection “Server= <dbserver>;Database= <dbname>;Trusted_Connection=True”
    Set-AcctDBConnection -DBConnection “Server= <dbserver>;Database= <dbname>;Trusted_Connection=True”
    Set-HypDBConnection -DBConnection “Server= <dbserver>;Database= <dbname>;Trusted_Connection=True”
    Set-ProvDBConnection -DBConnection “Server= <dbserver>;Database= <dbname>;Trusted_Connection=True”
    Set-PvsVmDBConnection -DBConnection “Server= <dbserver>;Database= <dbname>;Trusted_Connection=True”
    Set-BrokerDBConnection -DBConnection “Server= <dbserver>;Database= <dbname>;Trusted_Connection=True”

Note: It is important to verify that all the preceding Set-<service>DBConnection commands have returned a result of OK. In case, when the result is other than OK for any of these commands, it might be necessary to enable logging or tracing to determine the cause of the connection failure.

The XDDBDiag utility can be used to verify the consistency of your database after the move.

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-registers. No other action should be necessary.

More Information

Refer to the following Knowledge Center articles for more information:

  • CTX128364 – Error: An error has occurred while connecting to the requested resource


Leave a Reply

Your email address will not be published. Required fields are marked *

Turn on pictures to see the captcha *