How to restore a database from bak file from azure data studio on Mac

Adding this as an answer as I don't have enough rep to comment. This is in response to the question in the comment for the answer to the OP (If that's not confusing enough!)

This only applies when your sql database is hosted on a Mac/Linux/Docker Container. We don't have any Windows servers in our estate for me to test this on to see if the location of the .bak files is any different.

When you click on the "..." button, it browses to /var/opt/mssql/data on the machine (or docker container) the database is hosted on. This is not an issue if you are backing up & restoring databases on the same host, however, if you're migrating to a new server or just creating a dev/UAT/staging environment, it becomes a problem because you don't have access to var/opt/mssql/data.

This is a bit of a sledgehammer to crack a nut type solution but as I'm working with 2 dev boxes, it doesn't make a lot of difference to me.

To make this easier to understand I'll call the server that hosts the database you have backed up ProdServ & the server you are restoring to DevServ.

On DevServ, at a terminal prompt, navigate to /var/opt and make a note of the current permissions on the mssql directory (mine were drwxrwx---).

$ cd /var/opt

$ ls -la

Google the octal value for your permissions (in my instance, it's 770)

Change the permissions of the data directory to rwxrwxrwx.

$ chmod -R 777 /var/opt/mssql/data

(You will also need to do this on ProdServ if that is also a Unix-based o/s)

Copy the .bak files from ProdServ to DevServ via a method suitable to the environment you're working in.

Windows --> Linux I'd use WinSCP

For Mac to Docker, docker cp <fileToCopy> <container>:<destinationPath> works perfectly fine.

Once the files have been copied over, they will magically appear when you click the "..." button in azure data studio again. Make sure you change the directory permissions back to their original value via the same command. So in my instance, simply

$ chmod -R 770 /var/opt/mssql/data

As an extra note, if you're used to working in MSSMS, the wizard there allows you to create a database from a .bak file, from what I can see, Azure Data Studio does not. You have to create the database first (CREATE DATABASE <databasename>) in a query window, then restore the .bak file to it.


  • Go to Azure Data Studios > Settings
  • Edit settings by clicking on "new settings editor"
  • Search for "preview"
  • Scroll to the bottom and check "Enable unreleased preview features"