Restore a MS SQL Server backup on Linux
Published on
If you need to check the content of the backup you may use the following query:
Doing so will list the database stored in the backup file. What we are most interested in is the logical name, which is the name under which the DB appears and is queried through. For each database you should have two names: YourDatabase
and YourDatabase_Log
for the database and its logs respectively.
If you get an error stating that the file can’t be found, you may need to move it into a folder accessible to mssql. A dedicated backup folder inside the app directory is usually a good idea:
To actually restore the database, simply use:
The two MOVE
statement are the important part here since the backup will usually come from someone using WIndows, and will thus want to restore the database onto an invalid path.