Restoring a MS SQL Server database on Linux

by J86   Last Updated August 01, 2020 10:06 AM - source

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
➜  ~ 


Answers 1


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

Priyanka
Priyanka
January 17, 2020 05:30 AM

Related Questions



SQLServer Linux: Restore full database / Catalog

Updated July 13, 2018 08:06 AM

Table is marked as crashed and should be repaired

Updated June 08, 2017 12:06 PM