Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Import Database from Backup File on SQL Server for Linux / Docker
# Copy backup file to Docker Container
# Remember to name your container with the --name parameter on docker start, so you can
# replace the SQL_Server name on the following command.
# Remember also to change the backup file path.
docker cp ~/database.bak SQL_Server:/var/opt/mssql/data/
-- Use the following command to list the contents of the backup file.
-- Change database.bak for the file that you copied to your machine or container
-- The root path to sql server files is /var/opt/mssql/data/
FROM DISK = '/var/opt/mssql/data/database.bak'
-- Use the column LogicalName from the result o the command above to fill
-- the fields database_Data and database_Log on the following command.
-- Don't forget to change the backup file path and destination mdf and ldf file paths
FROM DISK = '/var/opt/mssql/data/database.bak'
WITH MOVE 'database_Data' TO '/var/opt/mssql/data/database.mdf',
MOVE 'database_Log' TO '/var/opt/mssql/data/database.ldf'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.