2

I am running Manjaro Linux and I am trying to restore a Microsoft SQL Server database from a .bak file.

I am trying to follow the official documentation, but it doesn't seem to work!

➜  ~ sudo sqlcmd -S localhost -U SA -Q "RESTORE DATABASE [bejebeje] FROM DISK = N'/home/jwan/Dropbox/projects/personal/bejebeje/backups/2018-04-13/BejebejeDb2018-04-13.bak' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS =5"
[sudo] password for jwan: 
Password: 
Msg 3201, Level 16, State 2, Server jwan-pc, Line 1
Cannot open backup device '/home/jwan/Dropbox/projects/personal/bejebeje/backups/2018-04-13/BejebejeDb2018-04-13.bak'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Server jwan-pc, Line 1
RESTORE DATABASE is terminating abnormally.

I also tried without the sudo and I got the same thing. What am I doing wrong?

UPDATE

I tried the suggestion in the comments, and it still didn't work, here's what I got:

➜  ~ sqlcmd -S localhost -U SA -Q "RESTORE DATABASE [bejebeje] FROM DISK = N'/home/jwan/sqlbackup/BejebejeDb2018-04-13.bak' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS =5" 
Password: 
Msg 3201, Level 16, State 2, Server jwan-pc, Line 1
Cannot open backup device '/home/jwan/sqlbackup/BejebejeDb2018-04-13.bak'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Server jwan-pc, Line 1
RESTORE DATABASE is terminating abnormally.
➜  ~ ls -l sqlbackup
total 5720
-rwxrwxrwx 1 jwan jwan 5854720 Apr 15  2018 BejebejeDb2018-04-13.bak
➜  ~ 
  • this looks like a security issue. SQL server runs under its own user, move the file to location the server has access, or use chmod 0755 on the file – zsheep Jan 16 at 20:55
  • sudo is just executing the sqlcmd under root, which does not do any of the file processing it only sent the command RESTORE to the server – zsheep Jan 16 at 20:59
  • How do I find out what directory the sql server user has access to? – J86 Jan 16 at 21:05
  • just create a directory sudo mkdir /sqlbackup then run sudo chmod 0777 /sqlbackup this allows anything to read,write and execute into the directory, copy the file into this directory make sure the file has the same access right run ls -l to see that info – zsheep Jan 16 at 21:25
  • I just tried, it still didn't work :/ – J86 Jan 16 at 21:32
0

Try to edit the script (/opt/mssql/lib/mssql-conf/mssql-conf.py) using text editor, It is line 1: #!/usr/bin/python22, which may be wrong.

I changed it #!/usr/bin/python2 Plz try this

| improve this answer | |
  • I did this when I installed mssql-server this isn't my issue though, as now I already have /python2 on that script. – J86 Jan 17 at 15:02

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.