How to Restore a Database in Azure Data Studio Using Docker

Egemen Eroglu
3 min readJul 12, 2024

--

Restoring a database is a common task for developers and database administrators. I will show you how to restore a database in Azure Data Studio using Docker. We will go through the process of copying a database backup file from your computer to a Docker container and restoring it in Azure Data Studio.

Prerequisites

Step 1: Verify Docker Installation

First, check if Docker is installed on your system:

docker --version

Step 2: Identify Container

List all running containers:

docker ps

The output should be like this: We will use the ‘NAMES’ value.

Step 3: Copy the Backup File to the Container

Since Azure Data Studio is running on a Docker container, it cannot access your local files directly. Therefore, we need to copy the backup file from your computer to the Docker container. Use the docker cp command to copy the file. We will copy the file to the /var/opt/mssql/backups directory in the container.

From ‘Actions’, click ‘Open in terminal’ button. It will show the terminal. Now, let’s create a directory before we load the data. I prefer it like this:

Now we can copy our backup file:

In my case, <container_id> is sql. (as you can see in the first screenshot)

docker cp “/Users/egemeneroglu/Desktop/Files/SQL/ETRADE.bak” <container_id>:/var/opt/mssql/backups/ETRADE.bak

Let’s give it a quick check:

Step 4: Restore the Database in Azure Data Studio

  • Open Azure Data Studio
  • Connect to Your SQL Server Container
  • Restore the Database

Warning: If you already have a database that has same name with your backup database name, it might give an error.

  • In the Restore Database dialog, choose Backup file as the Backup type.
  • Click on Browse and navigate to /var/opt/mssql/backups/ETRADE.bak in the file selection dialog.
  • Select the backup file and click OK.
  • Provide a new name for the database if you want to restore it under a different name.
  • Click Restore to begin the restoration process.

In the task panel, you can see the process and outputs:

Conclusion

Restoring a database in Azure Data Studio using Docker is a straightforward process once you know the correct steps. By following this guide, you can easily transfer and restore your database backup files. I hope you found this article helpful. If you have any questions or run into any issues, feel free to leave a comment below!

--

--

Egemen Eroglu
Egemen Eroglu

Written by Egemen Eroglu

I write articles about Data Engineering and Data Science | IT R&D Specialist @DHL Express

Responses (1)