Migrate SQL Server on Linux using the Azure SQL Migration extension for Azure Data Studio

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

This blog is authored by Kevin Barlett (Senior Customer Engineer, Customer Success Unit) and reviewed by Mohamed Kabiruddin (Senior Program Manager, Azure SQL)

 

In this article, we'll detail the process of migrating from SQL Server running on a Linux distribution to Azure SQL Managed Instance using the Azure SQL Migration extension in Azure Data Studio. 

 

When using the Azure SQL Migration extension to migrate your SQL Server database(s) running on Linux, the process is identical to SQL Server running on a Windows Operating System as detailed in the online or offline migration tutorials to Azure SQL Managed Instance.  The key difference, specifically when using a network share as the source for database backups, is the format and underlying configuration of the network share for Linux Operating System. 

 

When SQL Server is hosted on a Linux Operating System, the BACKUP DATABASE syntax shown below is not valid.  Linux does not natively support the SMB/CIFS protocols. 

 

MohamedKabiruddin_0-1635806276158.png

 

 

 

At the same time, the Azure SQL Migration extension does not support entering a local filesystem path as a source for backup files. This is not a limitation of the extension but instead is expected behavior as a result of the use of the self-hosted integration runtime (SHIR) to perform the backup file copy process

  

MohamedKabiruddin_1-1635806276160.png

 

 

MohamedKabiruddin_2-1635806276161.png

 

So how do databases written to a location on the local Linux filesystem find their way to a SMB file share that is compatible with the Azure SQL Migration extension? 

The answer is Samba / Azure Files file share and the CIFS-UTILS package.  Combined, these utilities unlock multiple migration scenarios from SQL Server on Linux to Azure SQL Managed Instance.

 

Let’s walk through several scenarios using Samba / Azure file share to enable database migrations from SQL Server on Linux using the Azure SQL Migration extension in Azure Data Studio.  

Note: This article leverages Samba in some of the scenarios listed below to enable easy migration from SQL Server on Linux to Azure. See install and configure Samba to learn more about the setup.

 

Migration Scenario 1 – Mount and write backups to an Azure Files file share

In this scenario, we’ll mount an Azure file share on the Linux server file system and write database backups there. 

On the Azure file share page in the Azure portal page, choose Connect.

 

bake13_0-1635882903271.png

 

The Connect blade will appear to the right.  In this example, we want to mount our migrationbackups Azure Files file share on a Linux server, so we’ll choose Linux.  Doing so will present the pre-written script necessary that performs the following:

  1. Create the /mnt/migrationbackups directory (remove that line if you have that directory already exists)
  2. Create a secured file containing the Azure file share credentials
  3. Add an entry to the /etc/fstab configuration file to ensure the Azure file share persists through server restarts
  4. Mounts the Azure file share to the /mnt/migrationbackups on the local server filesystem

bake13_1-1635883061024.png

 

After successful execution of the script, let’s backup the NorthWind database from our SQL Server on Linux environment to the /mnt/migrationbackups local directory.  Similar to the configuration described in the first migration scenario, the backup is actually being written to the file system that is mounted to /mnt/migrationbackups, which in this case is an Azure Files file share.

 

bake13_2-1635883111942.png

 

bake13_3-1635883119061.png

 

bake13_4-1635883124011.png

 

Now we can use the Azure SQL Migration extension in Azure Data Studio to migrate the NorthWind database, specifying the Azure file share as our source backup location.

 

bake13_5-1635883137916.png

 

Note that the Windows user account information you provide when using an Azure file share as the source backup location is slightly different.  Here, the Windows username is specified as localhost\storageAccountName  So in the example above, the Windows user for the Azure Files file share is localhost\myairsstorage.  For the file share password, use the value in the password= portion of the original script used to mount the Azure Files file share.

 

bake13_6-1635883218188.png

 

Migration Scenario 2 – Create an SMB share on a Linux OS

In this configuration we’ll use Samba to make the Linux file system location appear to be a SMB share and therefore enable it to be used with the Azure SQL Migration extension. 

This time we’ll backup the NorthWind database to the /var/opt/DBbackups/NorthWind directory.  That directory is configured within Samba to act as a SMB share (like a “Windows share”).   

 

MohamedKabiruddin_9-1635806276168.png

 

MohamedKabiruddin_10-1635806276169.png

And again, using Samba, you can connect to the BackupShareOnLinux SMB share that is hosted on the Linux server.   

 

bake13_0-1636137733577.png

 

Furthermore, that SMB file share path can now be used in the Azure SQL Migration extension to perform database migrations. 

 

MohamedKabiruddin_12-1635806276171.png

 

Migration Scenario 3 – Mount an SMB share on a Windows OS

In this scenario, the SQL Server instance is hosted on Ubuntu 16.04 LTS as shown below. 

 

MohamedKabiruddin_3-1635806276162.png

 

Let’s take a backup of the NorthWind database and write it to /var/opt/SQLbackups.  To SQL Server, this looks and behaves as if it were a local filesystem on the Linux server. 

 

MohamedKabiruddin_4-1635806276163.png

 

Looking at the backup history tables in the msdb database, we see that the database backup was successfully written to /var/opt/SQLbackups/NorthWind/NorthWind_FULL.BAK. 

 

MohamedKabiruddin_5-1635806276164.png

 

And we can also see the backup file in /var/opt/SQLbackups/NorthWind in Linux. 

 

MohamedKabiruddin_6-1635806276165.png

 

But using the power of Samba and CIFS-UTILS, the NorthWind database backup was actually written to the \\SAN0\DatabaseBackups\NorthWind SMB share.

 

MohamedKabiruddin_7-1635806276166.png

 

Now we can supply the SMB file share path in the Azure SQL Migration extension to perform the migration to Azure SQL Managed Instance. 

 

MohamedKabiruddin_8-1635806276167.png

 

 

In this article we described three database migration scenarios for SQL Server on Linux using Samba, Azure file share and CIFS-UTILS utilities with the Azure SQL Migration extension in Azure Data Studio.  

 

Happy migrations!

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.