Search code examples
sql-servermacosazurefinder

Access a database backup-file on mac? (.bak)


I'm running a localhost database through Docker on MAC. I have an assignment that requires me to hand in the .bak file along with the program I wrote. I'm using Azure Data Studio as DBMS. I can't find these anywhere and I've tried to google the matter but it doesn't seem as a common issue for other mac users.

Here is where the files are stored

How do i access these from Finder? Or is there another way to do this?


Solution

  • Accessing Docker Container File system from Mac OS host through this tutorial.

    1. To access the file system of a particular Container, first, let us get the Container ID using the inspect command on the Docker Host.

    docker inspect --format <Container Name>

    1. Use the Alpine Docker image and mount your Host file system to the container

    docker run --rm -it -v /:/vm-root alpine:edge sh

    We need the ID of this container. So, you could combine the step 1 and 2 with the following

    docker run --rm -it -e CONTAINER_ID=$(docker inspect --format <Container Name>) -v /:/vm-root alpine:edge sh

    Now we have the CONTAINER_ID set as an environment variable in the alpine container.

    1. Once you are in the alpine container, you can visit the following directory

    cd /vm-root/var/lib/docker

    1. Inside this directory, you will be able to access all the familiar files that you are used to when administering Docker

    2. Now, we need to find the mount-id for the selected container to access the file system directories. We will use the CONTAINER_ID environment variable obtained in step 2. I have AUFS as my file system driver for the this example. To do that, use the following command.

    MOUNT_ID=$(cat /vm-root/var/lib/docker/image/aufs/layerdb/mounts/$CONTAINER_ID/mount-id)

    1. The above step will give you the mount-id. Now you can access the file system of the container under mnt directory with the mount-id

    ls -ltr /vm-root/var/lib/docker/aufs/mnt/$MOUNT_ID