-1

I try to restore SQL Server 2017 Express database using sqlcmd tool on Ubuntu 16 Server.

My SQL command is:

RESTORE DATABASE [xxxxx] FROM DISK = N'/home/xxxxxx/DBBackups/xxxx.bak' WITH NORECOVERY, MOVE 'xxxx_Data' TO '/var/opt/mssql/data/xxxxx.mdf', MOVE 'xxxx_Log' TO '/var/opt/mssql/data/xxxx_log.ldf'

Error message is:

BackupDiskFile::OpenMedia: Backup device '/home/xxxxxx/DBBackups/xxxxxxxx.bak' failed to open. Operating system error 5(Access is denied.).

Using WITH MOVE option described in this post does not work.

UPDATE

Here's another post and still Access denied error.

0

1 Answer 1

6

The error indicates mssql doesn't have permissions to read the backup file. You can give other users (users other than the file's existing owner or group) read access to the backup file with the chmod example below. This will allow the mssql daemon user to read the backup file for the restore.

sudo chmod o+r /home/xxxx/DBBackups/xxxx.bak

Regarding your comment:

I don't know why Microsoft did not give mssql permissions to access all files

The mssql user isn't granted more permissions than it needs during the install, following the security principle of least privilege. Consequently, it won't have permissions to your home directory by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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