Get up to 50% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

On-premise SQL Server to Azure SQL Migration using Log Replay Service (LRS)-Part 3 Migration

On-premise SQL Server to Azure SQL Migration using Log Replay Service (LRS)-Part 3 Migration
  • Part 1: Introduction and requirements
  • Part 2: Preparing for migration
  • Part 3: Migration procedure (This article)
  • Part 4: Additional steps

Migration Procedure

Start the migration

You start the migration by starting LRS. You can start the service in either autocomplete or continuous mode.

When you use autocomplete mode, the migration will finish automatically when the last of the specified backup files has been restored. This option requires the start command to specify the filename of the last backup file.

When you use continuous mode, the service will continuously restore any new backup files that were added. The migration will finish on the manual cutover only.

Here we are using continuous mode, since we want to migrate the databases with minimal downtime.

Start LRS in continuous mode

Here’s an example of starting LRS in continuous mode by using PowerShell:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Start-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "SQLMIJagathRG" `
-InstanceName "sqlmanagedinstancejagath" -Name "AdventureWorks2016" `
-Collation "SQL_Latin1_General_CP1_CI_AS" `
-StorageContainerUri "https://storageaccountsqlmitest.blob.core.windows.net/sqlmibackup/AdventureWorks2016" `
-StorageContainerSasToken "mySASToken"

Here’s an example of starting LRS in continuous mode by using the Azure CLI:

az sql midb log-replay start -g SQLMIJagathRG --mi sqlmanagedinstancejagath -n AdventureWorks2016
   --storage-uri "https://storageaccountsqlmitest.blob.core.windows.net/sqlmibackup/AdventureWorks2016"
   --storage-sas "mySASToken"

Run LRS as background Job

PowerShell and CLI clients to start LRS in continuous mode are synchronous. This means that clients will wait for the API response to report on success or failure to start the job.

During this wait, the command won’t return control to the command prompt. If you’re scripting the migration experience, and you need the LRS start command to give back control immediately to continue with rest of the script, you can run PowerShell as a background job

with the -AsJob switch. For example:

$lrsjob = Start-AzSqlInstanceDatabaseLogReplay <required parameters> -AsJob

When you start a background job, a job object returns immediately, even if the job takes an extended time to finish. You can continue to work in the session without interruption while the job runs.

Monitor the migration progress

To monitor the progress of the migration through PowerShell, use the following command:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Get-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "SQLMIJagathRG" `
-InstanceName "sqlmanagedinstancejagath" -Name "AdventureWorks2016"

To monitor the progress of the migration through the Azure CLI, use the following command:

az sql midb log-replay show -g SQLMIJagathRG --mi sqlmanagedinstancejagath -n AdventureWorks2016

Stop the migration

If you need to stop the migration, use the following cmdlets. Stopping the migration will delete the restoring database on SQL Managed Instance, so resuming the migration won’t be possible.

To stop the migration process through PowerShell, use the following command:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Stop-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "SQLMIJagathRG" `
-InstanceName "sqlmanagedinstancejagath" -Name "AdventureWorks2016"

To stop the migration process through the Azure CLI, use the following command:

az sql midb log-replay stop -g SQLMIJagathRG --mi sqlmanagedinstancejagath -n AdventureWorks2016

Complete the migration (continuous mode)

If you started LRS in continuous mode, after you’ve ensured that all backups have been restored, initiating the cutover will complete the migration. After the cutover, the database will be migrated and ready for read and write access.

To complete the migration process in LRS continuous mode through PowerShell, use the following command:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Complete-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "SQLMIJagathRG" `
-InstanceName "sqlmanagedinstancejagath" -Name "AdventureWorks2016" `
-LastBackupName "MY-PF2HM3EY_AdventureWorks2016_LOG_20211219_230104.trn"

To complete the migration process in LRS continuous mode through the Azure CLI, use the following command:

az sql midb log-replay complete - g SQLMIJagathRG --mi sqlmanagedinstancejagath -n AdventureWorks2016 –last-backup-name "MY-PF2HM3EY_AdventureWorks2016_LOG_20211219_230104.trn"
Jagath Jayaprakash

Jagath Jayaprakash

ITO Service Delivery Consultant III at DXC Technology


Note

Disclaimer: The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Share :

Related Posts

On-premise SQL Server to Azure SQL Migration using Log Replay Service (LRS)-Part 1 Introduction

On-premise SQL Server to Azure SQL Migration using Log Replay Service (LRS)-Part 1 Introduction

Introduction This article explains how to configure database migration from SQL 2008 – 2019 to Azure SQL Managed Instance using Log Replay Service …

Kubernetes vs OpenShift – 15 Facts You Should Know

Kubernetes vs OpenShift – 15 Facts You Should Know

Welcome back to the OpenShift Bootcamp series. In this article we will see the difference between Kubernetes and OpenShift . Please note, during the …

How to Request Resource Quota Increase in Microsoft Azure

How to Request Resource Quota Increase in Microsoft Azure

As we know public cloud is offering unlimited* amount of resources and as an end user of public cloud we don’t need to worry about the backend …