Install Microsoft SQL Server & restore .bak on macOS

Install MSSQL & restore .bak on macOS

In building Nitro Porter, I need to help folks with an MSSQL database migrate to other software. Most often, you get a .bak file from someone running SQL Server. Unfortunately, that’s pretty difficult to wrangle when you’re using an M1 Macbook Pro.

It turns out there’s only really one path to do this, so if this method isn’t your preference, I’ve got some bad news for you: It’s your only option. This guide is a shortcut to a very bad day I had trying to figure out a compatible path for getting this working.

You will need:

  1. Docker
  2. Azure SQL Edge
  3. Azure Data Studio
  4. SQLPro for MSSQL (optional, but recommended)

First, get Docker, install it, and run it.

Second, get Azure SQL Edge as a Docker image with this command in Terminal:

docker pull mcr.microsoft.com/azure-sql-edge

Third, run the Docker image by modifying & running this command:

sudo docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=admin!!1' -p 1433:1433 --name sqledge -d mcr.microsoft.com/azure-sql-edge

You can name the container something other than sqledge and use a password other than admin!!1 but note it requires a letter, number, and a symbol in an 8+ character password. Note the username is ‘sa’ because that’s SQL Server’s version of root. The port is 1433.

Fourth, verify it’s running in Docker:

docker ps

Fifth, get Azure Data Studio and connect to localhost (“Connections” in the sidebar) using the info you initiated the Docker image with above.

Sixth, copy your .bak file into your Docker container. The first file is the source (is yours named this and in this folder? edit it!), the second is the destination. In this command, sqledge is the name of your container. The /tmp folder is a safe bet for destination.

docker cp ~/aspplayground.bak sqledge:/tmp/aspplayground.bak

Seventh, in Azure Data Studio, choose “Restore” and Restore From “Backup file” and type in the Backup File Path you copied the file to above. From there just complete the wizard.

Finally, use a tool like SQLPro for MSSQL to connect (same info again!) to verify the database imported / restored.

Feedback on this guide, or great success? Let me know! lincoln@icrontic.com