0

I have the following script with its corresponding backup file

USE [master]

RESTORE DATABASE [Imports]
FROM DISK = '/workspaces/Imports/.devcontainer/mssql/Imports.bak'
WITH MOVE 'Imports' TO '/var/opt/mssql/data/Imports.mdf',
MOVE 'Imports_log' TO '/var/opt/mssql/data/Imports_log.ldf',
FILE = 1,  NOUNLOAD,  STATS = 5
GO

In command line I execute this line

/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P MSSqlPasswd -d master -i /workspaces/Imports.devcontainer/mssql/restoreDataBases.sql

but I get this error

Changed database context to 'master'.

Msg 3201, Level 16, State 2, Server 8738a617a215, Line 2
Cannot open backup device '/workspaces/Imports/.devcontainer/mssql/Importaciones.bak'. Operating system error 2
(The system cannot find the file specified.).

Msg 3013, Level 16, State 1, Server 8738a617a215, Line 2
RESTORE DATABASE is terminating abnormally.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pedro Mora
  • 375
  • 1
  • 4
  • 16
  • Does the `mssql` user/group have access to read `/workspaces/Imports/.devcontainer/mssql`? – Thom A May 24 '22 at 18:04
  • @Larnu I don't see a `mssql` user. Instead of that there's a `vscode` user. I think is the one executing the container build and run processes. It has all permissions – Pedro Mora May 24 '22 at 18:34
  • `mssql` is the user that SQL Server on Linux runs under. As the error tells you, it doesn't have access to the path. If you check the permissions on `/var/opt/mssql/data/` you'll see than the user and group are likely `mssql` with the permissions 770. – Thom A May 24 '22 at 19:57
  • @Larnu but how can I give access to an unexistent user? – Pedro Mora May 24 '22 at 22:03

0 Answers0