- 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:
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:
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:
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:
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"