This download contains code and deployment instructions required for the functionality described in the article "Preparing for the Unthinkable - a Disaster/Recovery Implementation" 
published on www.sqlservercentral.com.

The following is a map of the download-folder structure.

- DB-scripts folder:
  (i) "DB-scripts\CentralDb" subfolder: scripts for the CentralDb database; this is the database located in a central admin server.
      
      "DB-scripts\CentralDb\jobs" subfolder: job scripts to be deployed to the central admin server:
      - Document "DBA - DRsync.dtsx__deployment-how-to.docx" describes how to deploy SSIS package DRsync.dtsx (located in SSIS\DRsync) and how to configure it as a SQL Server Agent job 
        on the central-admin SQL instance.
      - Document "DBA - DRSync - GetDRSyncInfoToFiles.ps1__deployment-how-to.docx" describes how to deploy and configure job "DBA - DRSync - GetDRSyncInfoToFiles.ps1" 
        on the central-admin SQL instance.

  (ii) "utildb" subfolder: scripts for the utildb database; this is a database located on all production and D/R SQL server instances monitored by the DRsync utility.
      (a) Create utildb database;
      (b) Run script "DB-scripts\utildb\tables.sql" in utildb to create the database tables;
      (c) Run script "DB-scripts\utildb\procedures.sql" in utildb to create the stored procedures.

- SSIS folder: contains the BIDS solution of the DRsync.dtsx SSIS package; the actual package is in the SSIS\DRsync subfolder.


------------------------------------------
Roadmap for Extending the DRsync Framework
------------------------------------------

To add new configurational categories to the DRsync framework follow these steps 
(to illustrate, we will describe the following procedure in terms of the server-logins category):

(1) Decide which settings to focus on and create base table in utildb database for storing the data, eg. see drsync_logins table;
(2) Create table in utildb database for storing config differences between production and D/R, eg. see drsync_logins_compare table;
(3) Create stored procedure for storing the data in the table created in step (1) eg. drsync_logins table - see procedure DRsync_populate_logins;
(4) Update stored procedure DRsync_populate by adding a line to the code that executes the procedure from step (3): 
    eg. "EXEC [dbo].[DRsync_populate_logins];"
(5) Create stored procedure for storing configurational differences between the production and D/R environments in the table created in step (2)
    , eg. drsync_logins_compare table - see procedure DRsync_populate_logins_compare;
(6) Create stored procedure for reporting on differences in settings between the production and D/R environments, eg. see DRsync_logins_diff_settings_report;
(7) Create stored procedure for reporting on objects existing only in one environment and not the other, eg. see DRsync_logins_only_on_one_server_report;
(8) Update stored procedure DRsync__compare_all_settings_report by adding lines to the code to execute each of the procedures from steps (6) and (7);
    eg.:
    EXEC [dbo].[DRsync_logins_only_on_one_server_report] @ProdServer = @ProdServer, @DRServer = @DRServer;
    EXEC [dbo].[DRsync_logins_diff_settings_report] @ProdServer = @ProdServer, @DRServer = @DRServer; 
(9) Update SSIS package:
    - Add a data-flow task to copy the configurational data from production to the D/R environment: eg. see task "Copy Login Data from PROD to DR";
    - Add an Execute-SQL task to populate table drsync_xxxx_compare through the stored procedure created in step (5); 
      eg. drsync_logins_compare table populated by stored procedure DRsync_populate_logins_compare in Execute-SQL task "Populate table drsync_logins_compare - DR";
    - Connect the two newly added tasks to each other and to the rest of the tasks in the SSIS package; see how the two example SSIS tasks above are linked in the package.