5

We are trying to move a SQL server DB from Windows to Linux. But we are facing few problems while migration.

  1. We took a Backup of the DB server, from SSMS in Windows
  2. We restored it in the linux running the following commands:
RESTORE FILELISTONLY FROM DISK =N'/var/opt/mssql/data/backup_file_name.bak' 
RESTORE DATABASE DB_NAME 
 FROM DISK = N'/var/opt/mssql/backup_file_name.bak' WITH FILE = 1, 
 MOVE N'DB_NAME' TO N'/var/opt/mssql/data/DB_NAME.mdf', 
 MOVE N'DB_NAME_Log' TO N'/var/opt/mssql/data/DB_NAME.ldf', 
 NOUNLOAD, REPLACE, STATS = 1
GO

Running this I get an error more or less lie this:

file XX_FlatFline cannot be restored to PATH_IN_WINDOWS {.....mdf}. Use WITH MOVE to identify a valid location for the file.

I get error for both MDF and LDF files. The windows path shown above in the error is the location of the mdf and ldf files in the Windows machine.

Can someone help me understand what's going wrong here? Why does the Windows path still matter when I am restoring the dump into a new DB?

Warning: I am a novice in SQL Server.

asked Sep 8, 2017 at 19:12
3
  • 9
    What are the results of RESTORE FILELISTONLY (specifically, logical_file_name of each file)? The XX_FlatFline value in the error message was not specified in a MOVE clause so restore is trying to attempt to restore the file to the original file location (a Windows path). Commented Sep 8, 2017 at 20:39
  • 1
    Did you had a chance to check what Dan Guzman suggested Commented Sep 9, 2017 at 18:11
  • Big +1 to giving us the results of the RESTORE FILELISTONLY. I think I know the problem and this will confirm it. Think your MOVE statemens are incorrect or you have some missing. Commented Nov 12, 2017 at 23:59

1 Answer 1

0

In the first release of SQL Server on Linux, I saw that SQL Server translates paths to related terms in windows, for example, root '/' will be C:. so if this logic exists, you may try to make it something like:

FROM DISK = N'C:\var\opt\mssql\backup_file_name.bak' WITH FILE = 1

but I think it's different now as mentioned here maybe you should first check the version of your SQL Server on Linux and then check the steps on that article.

answered Nov 6, 2017 at 11:39

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.