Recovering from a Dynamics CRM 2011 Database Server failure

In the case of a Dynamics CRM 2011 Database Server failure, the database must be restored from the backup and reassociated with Dynamics CRM 2011.

How to do it…

Perform the following steps to recover from a SQL Server failure:

  1. In the case of a Full Server machine crash or failure, we might need to reinstall the operating environment of the server machine. Hence, we have to install the Windows Server version and make sure that the machine is joined to the same domain where Microsoft CRM Server is joined. Thereafter, we have to install the SQL Server version.
    Note

    We have to use the same database name and disk structure. If we changed the database name, additional steps would be needed to associate it back with Dynamics CRM 2011 Server.

  2. Log in to SQL Server Management Studio using Windows Authentication with a user credential, having CREATE DATABASE permissions on the instance of the SQL Server.
  3. On the recovery path, the first step would be to recover the master database, provided we have a backup of this database. To recover any system database, the database has to be started in single user mode.

    More information about starting a SQL Server instance in single user mode can be found at the following link:

    http://msdn.microsoft.com/en-IN/library/ms188236.aspx

    Then to restore the full backup of the master database, type the following T-SQL statement:

    RESTORE DATABASE master FROM <backup_device> WITH REPLACE

    Replace <backup_device> with the file location in a backup device, for example, T:\MS_CRM_Master_DB_Backup\master.bak.

    Note

    If changes are made after the database has been backed up, these changes will be lost once the backup is restored. After the master database is restored, the instance of SQL Server may stop automatically. Please restart the SQL Server instance if required.

  4. Post the master database restoration, the msdb database has to be restored. Before restoring msdb, stop the SQL Server Agent instance. Then, use the following T-SQL command to restore the msdb database:
    RESTORE DATABASE msdb FROM <backup_device> WITH REPLACE

    Replace <backup_device> with the file location in a backup device, for example, T:\MS_CRM_Master_DB_Backup\msdb.bak.

    Note

    It is necessary to restore msdb once the master database has been restored. The msdb database contains scheduling and other data used by the system. If msdb is not restored, and is not accessible, SQL Server Agent cannot access or initiate any previously scheduled tasks.

  5. Next, restore the MSCRM_CONFIG database and then all the organization databases. Execute the following T-SQL command to restore these databases:
    RESTORE DATABASE MSCRM_CONFIG FROM <backup_device> WITH REPLACE
    
    RESTORE DATABASE <Organization_MSCRM> FROM <backup_device> WITH REPLACE

    Replace <backup_device> with the file location in a backup device, for example, T:\MS_CRM_Master_DB_Backup\MSCRM_CONFIG.bak.

  6. In case SQL Server Reporting Services and Microsoft Dynamics CRM 2011 Connector for Microsoft SQL Server Reporting Services are also installed on the same machine, ReportingServer and ReportingServertempDB are also required to be restored using the RESTORE DATABASE command as shown in the following T-SQL commands:
    RESTORE DATABASE ReportingServer FROM <backup_device> WITH REPLACE
    
    RESTORE DATABASE ReportingServertempDB FROM <backup_device> WITH REPLACE

    Replace <backup_device> with the file location in a backup device, for example, T:\MS_CRM_Master_DB_Backup\ReportingServer.bak.

  7. Finally, we need to run the Microsoft Dynamics CRM 2011 Server setup as stated in the Installing Dynamics CRM Server recipe of Chapter 1, Installing Dynamics CRM 2011. But in this case, in the Specify Deployment Options page, we have to select the Connect to existing databases option.
    Note

    This step should only be tried in case the MSCRM_CONFIG database has been restored. If this database has not been restored (because it was not required), then we can reconnect to this database using the deployment manager. Please follow the Editing the organization's details recipe as stated in Chapter 1, Installing Dynamics CRM 2011, and change the SQL Server value.

How it works…

In this recipe, we have recovered all the databases required to make Dynamics CRM 2011 function step by step. The discussed scenario was a case of a Full Server failure. In case of a partial failure, we might need to restore a specific database. If the MSCRM_CONFIG database is not restored, it has only to be reconnected to Dynamics CRM 2011 Server as stated in step 7 of this recipe.