4

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?

  • 1
    Check this: dba.stackexchange.com/questions/217157/… – CR241 Nov 2 '18 at 22:20
  • 2
    Are you able to restore using 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';" – Dan Guzman Nov 3 '18 at 11:38
  • @DanGuzman that worked! Thanks! If you write that up as an answer I'll mark it as such – Brian Gradin Nov 5 '18 at 18:40
1

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';"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.