-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.

asked Mar 9, 2019 at 23:20
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.

answered Mar 10, 2019 at 2:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.