Created
April 12, 2018 12:54
-
-
Save rhuanbarreto/7000c5f3ac47b3d17ff264e03d0c1faa to your computer and use it in GitHub Desktop.
Import Database from Backup File on SQL Server for Linux / Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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/ | |
RESTORE FILELISTONLY | |
FROM DISK = '/var/opt/mssql/data/database.bak' | |
GO | |
-- 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 | |
RESTORE DATABASE NAV_ODS_2016 | |
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