Sql-server – Why is the database restore being aborted

azurelinuxsql serversql-server-2017

I'm trying to restore a SQL Server 2016 database into a SQL Server 2017 docker instance (microsoft/mssql-server-linux:latest). The process seems to be:

  1. Create docker container: docker run -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=<strong password>’ -p 1433:1433 --name 'sql1' microsoft/mssql-server-linux
  2. Create backup directory: docker exec -it sql1 mkdir /var/opt/mssql/backup
  3. Copy backup to directory: docker cp Foobar.bak sql1:/var/opt/mssql/backup
  4. Login to mssql server: mssql -o 1433 -u sa -p
  5. Get list of backed up files: restore filelistonly from disk='/var/opt/mssql/backup/Foobar.bak' <- each row returned will result in a move command in the next step
  6. Restore database: restore database Foobar from disk='/var/opt/mssql/backup/Foobar.bak' with stats=10, replace, move 'Foobar' to '/var/opt/mssql/data/Foobar.mdf', move 'Foobar_log' to '/var/opt/mssql/data/Foobar.ldf'

The last step is failing with the output:

Error: The backup or restore was aborted.

I tried to find an error log, and found /var/opt/mssql/log/errorlog. AFAICT, nothing gets output in this file from my aborted restore operation.

How can I determine what is happening? Are there logs available that I can use to get more info?

Best Answer

An easy way to execute any ad-hoc query within your container, including RESTORE, is with SQLCMD:

docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -Usa -P<strong password> -Q"restore database Foobar from disk='/var/opt/mssql/backup/Foobar.bak' with stats=10, replace, move 'Foobar' to '/var/opt/mssql/data/Foobar.mdf', move 'Foobar_log' to '/var/opt/mssql/data/Foobar.ldf';"