Skip to main content

Докер SQL Server

 

sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=LinuxMint333" \
   -p 1433:1433 --name sql1 --hostname sql1 \
   -d \
   mcr.microsoft.com/mssql/server:2022-latest
 docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "LinuxMint333"
scp /var/opt/db/BACKUP/VSM_School-sample_Web_2024_02_19.bak test@test8-pc:/tmp
 docker cp /var/opt/db/BACKUP/VSM_School-sample_Web_2024_02_19.bak sql1:/home/VSM_School-sample_Web_2024_02_19.bak

 

 USE [master] RESTORE DATABASE [VSM_School-sample_Web] FROM  DISK = N'/home/VSM_School-sample_Web_2024_02_19.bak' WITH  FILE = 1, MOVE N'VSM_Gusev1_Web' TO N'/var/opt/db/DATA/ExtraSql/School-sample_Web.mdf', MOVE N'VSM_Gusev1_Web_MSGS' TO N'/var/opt/db/DATA/ExtraSql/School-sample_Web.ndf', MOVE N'VSM_Gusev1_Web_1' TO N'/var/opt/db/LOG/ExtraSql/School-sample_Web_1.ldf',  NOUNLOAD,  STATS = 5

 

docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "LinuxMint333" -Q "USE [master] RESTORE DATABASE [VSM_School-sample_Web] FROM DISK = N'/home/VSM_School-sample_Web_2024_02_19.bak' WITH FILE = 1, MOVE N'VSM_Gusev1_Web' TO N'/var/opt/db/DATA/ExtraSql/School-sample_Web.mdf', MOVE N'VSM_Gusev1_Web_MSGS' TO N'/var/opt/db/DATA/ExtraSql/School-sample_Web.ndf', MOVE N'VSM_Gusev1_Web_1' TO N'/var/opt/db/LOG/ExtraSql/School-sample_Web_1.ldf', NOUNLOAD, STATS = 5;"


sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "LinuxMint333" -Q "RESTORE FILELISTONLY FROM DISK = N'/home/VSM_School-sample_Web_2024_02_19.bak';"


USE [master] 
RESTORE DATABASE [VSM_School-sample_Web] FROM DISK = N'/var/opt/mssql/backup/VSM_School-sample_Web_2024_02_19.bak' 
WITH FILE = 1, 
MOVE N'VSM_School-sample_Web' TO N'/var/opt/mssql/data/ExtraSql/VSM_School-sample_Web.mdf', 
MOVE N'VSM_School-sample_Web_MSGS' TO N'/var/opt/mssql/data/ExtraSql/VSM_School-sample_Web.ndf', 
MOVE N'VSM_School-sample_Web_1' TO N'/var/opt/mssql/log/ExtraSql/VSM_School-sample_Web_1.ldf', 
NOUNLOAD, 
STATS = 5;

 

sudo systemctl enable kestrel-school-sample.nbics.net-service.service
sudo systemctl start kestrel-school-sample.nbics.net-service.service