How to Backup and Restore your XenApp/XenDesktop Database

How to Backup and Restore your XenApp/XenDesktop Database

book

Article ID: CTX135207

calendar_today

Updated On:

Description

This article describes how to back up and restore a XenDesktop database on Microsoft SQL Server.

Requirements

This article assumes you are an SQL administrator with basic knowledge of SQL Server or appropriate resources to assist with the execution of the SQL statement command.

Background

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.


Instructions

Backup

The following process describes how to perform a one-time, manual backup. It does not prevent the need to perform scheduled backups of the database. This backup captures a snapshot of the database at that time it is performed. It is recommended that no administrative changes be performed while the backup is in progress.

Complete the following procedure:

  1. Verify the name of the database and database server that is currently used by starting PowerShell from the Desktop Studio Console.
    User-added image

  1. Run the following command:  Get-BrokerDBConnection to get the name of the database server/Data Source and the Database/Initial Catalog name.
    Example 1
    PS C:\> Get-BrokerDBConnection
    Server= sqlserver.training.local;Database= CitrixXenDesktopDB ;Trusted_Connection=True"

    Example 2
    PS C:\> Get-BrokerDBConnection
    Data Source=SQLServer; Failover Partner=SQLServer2; Initial Catalog=CitrixXenDesktopDB; Integrated Security=True; Network=dbmssocn

  1. Connect to the SQL server and open the Microsoft SQL Server Management Studio.     

  2. Connect to the Database Engine.
    User-added image

  1. Expand the Databases node for your server and navigate to the database identified in Step 2.
    User-added image

  1. Right-click database, select Tasks > Back Up.
    User-added image

  1. Verify that the backup type is set to Full and verify the information listed. There is an option you can leverage to verify the backup when finished.
    User-added image

  1. Cick OK and ensure that the backup completed successfully.
    User-added image

See Creating Full and Differential Backups of a SQL Server Database.

Restore

Important

  • Remove any hotfixes applied after the backup before performing the restore.

  • As a precaution, back up the present database before the restore.

The following process describes how to perform a restore from the backup done in the previous section. This process returns the database to the point in time when the backup was performed. Any changes made after that point in time will be lost.

Complete the following procedure: 

  1. Connect to the Database Engine.
    User-added image

  1.  Expand the Databases node for your server and navigate to the name of your XenDesktop database.
    User-added image

  1. Right-click database, select Tasks Restore > Database
    User-added image

  1. Select the backup set that you want to restore from the list or go to the next step on how to select a file.
    User-added image

    The source can be changed to From device then select the browse “…” icon
    User-added image

  1. Select Add to locate the backup file from its folder.
    User-added image

  1. Ensure the correct backup set is selected then click Options.
    User-added image

  1. From Options , click Overwrite the existing database and Restore with recovery.
    User-added image

  1. Click OK.
    User-added image

  1. Restart Each Broker.

  2. From each broker, open  a PowerShell prompt and run the following commands to verify the status of each service:

    Add-PSSnapin Citrix.*
    Get-AcctServiceStatus
    Get-BrokerServiceStatus
    Get-ConfigServiceStatus
    Get-HypServiceStatus
    Get-LicServiceStatus
    Get-ProvServiceStatus
    Get-PvsVmServiceStatus

    Note: Verify that all preceding commands 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.

  1. Use the XDDBDiag utility - CTX128075 - XDDBDiag for XenDesktop  to verify the consistency of the database after the restore. If any Virtual Desktop Agents were running when the DDC services were shut down in Step 1, it could take up to 10 minutes before the Virtual Desktop Agents reregister. No other action is required.

  2. Read to the Desktop groups all changes including catalogs, hosts, or assignments made after the backup date.

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

This article describes how to backup and restore your XenDesktop Database.

Additional Information

CTX128075 - XDDBDiag for XenDesktop
CTX127254 - XenDesktop 5.6 SDK Cmdlet Help
CTX114501 – Supported Databases for Citrix Products
CTX130532 – How to Restore a XenDesktop 5 Database on a SQL 2008 Server