2

I have setup a GitHub Codespaces environment that includes a SQL Server container.

Inside /.devcontainer/docker-compose.yml i have something like this;

# ... other containers configururation
  db:
    image: mcr.microsoft.com/mssql/server:2019-latest
    restart: unless-stopped
    environment:
      ACCEPT_EULA: Y

The SQL Server spins-up, but I don't know how can I restore a database on that server. When I run a VS Code DevContainer locally on docker I can just copy the file to the SQL Server container with the docker cp command, and then run the script to restore the database from there. But I don't know how to approach this task with Codespaces.

Any ideas appreciated.

Lev
  • 583
  • 3
  • 15
  • This feels like the question isn't how do you restore the database on the server, but how to you get the file onto the codespaces container so that you *can* restore it. – Thom A Aug 22 '21 at 19:28
  • Yes, but if there is some a workaround where I don't have to copy the file to the container it would also work for me. – Lev Aug 22 '21 at 19:30
  • The file has to be in an location accessible for the instance; on a container most of the time that means within the container. – Thom A Aug 22 '21 at 19:32

1 Answers1

2

One option would be to use Spawn (disclaimer - I'm one of the devs working on it).

Spawn lets you create "data images" which represent readonly snapshots of a database at a point in time. These can be created from backups (including SQL Server backups - check out the docs).

Once done, you can create "data containers" which are instantly provisioned cloud-hosted copies of Spawn data images that can be consumed in any environment - including GitHub codespaces.

We've written about how to use Spawn data containers in GitHub Codespaces here.

cjheppell
  • 386
  • 2
  • 8