Error trying to import .bak file from Sql Server on Linux

2

I am very new to SQL Server and am trying to import a .bak file from a backup that came from another server (Windows) on Linux (Linux mint 19)

The command I used on the terminal was this :

sqlcmd -S localhost -U SA -Q "RESTORE DATABASE [demodb] FROM DISK = N'/home/usuario/html/projeto_sql/backup.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5"

The errors are:

Msg 5133, Level 16, State 1, Server homepc, Line 1
Directory lookup for the file "E:\Banco Dados\Banco1.mdf" failed with the operating system error 2(The system cannot find the file specified.).

Msg 3156, Level 16, State 3, Server homepc, Line 1
File 'Banco1' cannot be restored to 'E:\Banco Dados\Banco1.mdf'. Use WITH MOVE to identify a valid location for the file.

Msg 5133, Level 16, State 1, Server homepc, Line 1
Directory lookup for the file "E:\Banco Dados\Banco1_log.ldf" failed with the operating system error 2(The system cannot find the file specified.).

Msg 3156, Level 16, State 3, Server homepc, Line 1
File 'Banco1_log' cannot be restored to 'E:\Banco Dados\Banco1_log.ldf'. Use WITH MOVE to identify a valid location for the file.

Msg 3119, Level 16, State 1, Server homepc, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.

Msg 3013, Level 16, State 1, Server homepc, Line 1
RESTORE DATABASE is terminating abnormally.

OBS:

  • My version of SQL SERVER running is

    Microsoft SQL Server 2017 (RTM-CU13) (KB4466404) - 14.0.3048.4 (X64)     Nov 30 2018 12:57:58     Copyright (C) 2017 Microsoft Corporation     Developer Edition (64-bit) on Linux (Linux Mint 19.1)

  • I do not know which version of SQL Server / or how the .bak file was created, does it matter?

  • asked by anonymous 25.12.2018 / 16:09

    1 answer

    1

    SQL Server 2017 for Linux is compatible with Ubuntu 16.04; I do not know if it is stable in Linux Mint 19.1, which is derived from Ubuntu 18.04. In the Installing SQL Server 2017 for Linux on Ubuntu 18.04 LTS is how to install SQL Server 2017 for Linux on Ubuntu 18.04.

    The REPLACE option is only required when the database already exists and you want to replace it with the contents of the backup. Because the database was created in another operating environment, remove REPLACE and use WITH MOVE . The complete instructions on how to restore the backup in the GNU / Linux distribution are at Migrate to SQL Server database from Windows to Linux using backup and restore .

    Example:

    RESTORE DATABASE Banco1 
       FROM DISK = '/home/usuario/html/projeto_sql/backup.bak'
       WITH MOVE 'Banco1' TO '/home/usuario/html/projeto_sql/Banco1.mdf',
            MOVE 'Banco1_Log' TO '/home/usuario/html/projeto_sql/Banco1_Log.ldf'
    GO
    

    I suggest that you install Azure Data Studio to manipulate SQL Server directly in the GNU / Linux graphical user interface. Get it in SQL Server , menu SQL Server , item download .

        
    25.12.2018 / 22:20