1
votes

I can not take backup .bak from my database in Linux ubuntu

See this image I want to backup from conn1 database: CarSaleDatabase

Image

I run this

USE CarSaleDatabase
GO 

BACKUP DATABASE CarSaleDatabase
TO DISK = '/home/mohammadsgh/github/ddblab.bak'

but I get this error:

Msg 3201, Level 16, State 1, Line 5 Cannot open backup device '/home/mohammadsgh/github/ddblab.bak'. Operating system error 5(Access is denied.). Msg 3013, Level 16, State 1, Line 5 BACKUP DATABASE is terminating abnormally.

How can I do this?

1
You didn't actually show us the SQL you ran... - Larnu
That's a hyperlink, to documentation. That doesn't tell us what SQL you ran... - Larnu
You back up a database by running SQL... Specifically the BACKUP DATABASE statement. What was the SQL you ran the get the error..? We can't help you if you don't he'll us help you - Larnu
You should be using the edit feature to tell is that. As for the error, Linux doesn't use \\ for directory separators, it uses /. Also, I doubt that the mssql user/group has access to that directory. - Larnu
I can't really expand much more on that. I doubt that the user mssql or the group mssql has access to the directory you want to back up in. It also probably shouldn't, seeing as it's a user's home directory - Larnu

1 Answers

1
votes

First step

create .bak file:

touch db.bak

second step:

sudo chmod 777 db.bak