Migration Type: Delta Migrations

Migration Type: Delta Migrations

A "Delta" migration is necessary when you migrate some data now and some data later.

To do a Delta migration, please follow the steps below after you have complete the initial backup and restore.

1.  Create the "Phase 2" Backup

Using Universal Migrator, perform a new backup of the source system.

2.  Re-Apply your Playbook to "Phase 2"

Warning
This is an important step.  Don't forget it.
Now, re-apply your playbook to the Phase2 database.  This is necessary so that any customizations, tweaks, or synthesized records get carried into the new Phase2 database.

3.  Copy Result_Ids from "Phase 1" to "Phase 2"

Info
Replace the Database Names
In the following script, replace PHASE1_DB and PHASE2_DB with the names of the respective database names.

If you want to copy the Result_Ids for all tables, simply use the query below.


  1. DECLARE @PHASE1_DB NVARCHAR(MAX) = 'REPLACE_WITH_PHASE1_DATABASE_NAME'
    DECLARE @PHASE2_DB NVARCHAR(MAX) = 'REPLACE_WITH_PHASE2_DATABASE_NAME'

    DECLARE @SCRIPT_INNER NVARCHAR(MAX) = '

    UPDATE
    [PHASE2_DB].?
    SET
    Comment = Phase1.Comment,
    Action_Group = Phase1.Action_Group,
    Action_Priority = Phase1.Action_Priority,
    Log_History = Phase1.Log_History,
    Log_Duration_Total = Phase1.Log_Duration_Total,
    Log_Updated_At = Phase1.Log_Updated_At,
    Result_Id = Phase1.Result_Id,
    Result_ReferenceCode = Phase1.Result_ReferenceCode,
    Result_Content = Phase1.Result_Content,
    Result_Content_Url = Phase1.Result_Content_Url,
    Result_View_Url = Phase1.Result_View_Url
    FROM
    [PHASE1_DB].? Phase1,
    [PHASE2_DB].? Phase2
    WHERE 1=1
    and Phase1.Id = Phase2.Id
    and Phase2.Result_Id = ''''
    '

    SET @SCRIPT_INNER = REPLACE(@SCRIPT_INNER, '''', '''''')

    DECLARE @SCRIPT NVARCHAR(MAX) = '


    USE [PHASE1_DB]

    DECLARE @SCRIPT NVARCHAR(MAX) = ''
    [SCRIPT_INNER]
    ''

    EXEC sp_MSforeachtable @SCRIPT

    '

    SET @SCRIPT = REPLACE(@SCRIPT, '[SCRIPT_INNER]', CONCAT('', @SCRIPT_INNER, ''))
    SET @SCRIPT = REPLACE(@SCRIPT, '[PHASE1_DB]', CONCAT('[', @PHASE1_DB, ']'))
    SET @SCRIPT = REPLACE(@SCRIPT, '[PHASE2_DB]', CONCAT('[', @PHASE2_DB, ']'))

    EXEC sp_executesql @SCRIPT


4.  Restore / Tweak using the "Phase 2" Backup

After the above script runs, the "Phase 2" database will now have Result_Ids in it.  This will allow you to safely restore or tweak records.