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.
Here’s an example of starting LRS in continuous mode by using PowerShell:
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"
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.
To monitor the progress of the migration through PowerShell, use the following command:
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
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:
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
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:
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"
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.