Skip to content

Commit d3015a6

Browse files
Merge pull request #32889 from rwestMSFT/rw-0121-fix-363433
Fix sqlcmd path (UUF 363433)
2 parents 6789bac + c5c3c25 commit d3015a6

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

docs/linux/tutorial-restore-backup-in-sql-server-container.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Restore a SQL Server Database in a Linux Container
33
description: This tutorial shows how to restore a SQL Server database backup in a new Linux container.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 11/18/2024
6+
ms.date: 01/21/2025
77
ms.service: sql
88
ms.subservice: linux
99
ms.topic: conceptual
@@ -191,7 +191,7 @@ This section provides deployment options for your environment.
191191

192192
::: moniker-end
193193

194-
### Change the SA password
194+
### Change the system administrator (SA) password
195195

196196
[!INCLUDE [change-docker-password](includes/change-docker-password.md)]
197197

@@ -223,18 +223,18 @@ This tutorial uses the [Wide World Importers sample databases for Microsoft SQL]
223223
The backup file is now located inside the container. Before restoring the backup, it's important to know the logical file names and file types inside the backup. The following Transact-SQL commands inspect the backup and perform the restore using **sqlcmd** in the container.
224224

225225
> [!TIP]
226-
> This tutorial uses **sqlcmd** inside the container, because the container comes with this tool pre-installed. However, you can also run Transact-SQL statements with other client tools outside of the container, such as [SQL Server extension for Visual Studio Code](../tools/visual-studio-code/sql-server-develop-use-vscode.md) or [Use SQL Server Management Studio on Windows to manage SQL Server on Linux](sql-server-linux-manage-ssms.md). To connect, use the host port that was mapped to port 1433 in the container. In this example, that is `localhost,1401` on the host machine and `Host_IP_Address,1401` remotely.
226+
> This tutorial uses **sqlcmd** inside the container, because the container comes with this tool preinstalled. However, you can also run Transact-SQL statements with other client tools outside of the container, such as [SQL Server extension for Visual Studio Code](../tools/visual-studio-code/sql-server-develop-use-vscode.md) or [Use SQL Server Management Studio on Windows to manage SQL Server on Linux](sql-server-linux-manage-ssms.md). To connect, use the host port that was mapped to port 1433 in the container. In this example, the host and port are `localhost,1401` on the host machine, and `Host_IP_Address,1401` remotely.
227227
228228
1. Run **sqlcmd** inside the container to list out logical file names and paths inside the backup. This is done with the `RESTORE FILELISTONLY` Transact-SQL statement.
229229

230230
```bash
231-
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost \
231+
sudo docker exec -it sql1 /opt/mssql-tools18/bin/sqlcmd -S localhost \
232232
-U sa -P '<new-password>' \
233233
-Q 'RESTORE FILELISTONLY FROM DISK = "/var/opt/mssql/backup/wwi.bak"' \
234234
| tr -s ' ' | cut -d ' ' -f 1-2
235235
```
236236

237-
You should see an output similar to the following:
237+
The results should look similar to the following output:
238238

239239
```output
240240
LogicalName PhysicalName
@@ -248,12 +248,12 @@ The backup file is now located inside the container. Before restoring the backup
248248
1. Call the `RESTORE DATABASE` command to restore the database inside the container. Specify new paths for each of the files in the previous step.
249249

250250
```bash
251-
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
251+
sudo docker exec -it sql1 /opt/mssql-tools18/bin/sqlcmd \
252252
-S localhost -U sa -P '<new-password>' \
253253
-Q 'RESTORE DATABASE WideWorldImporters FROM DISK = "/var/opt/mssql/backup/wwi.bak" WITH MOVE "WWI_Primary" TO "/var/opt/mssql/data/WideWorldImporters.mdf", MOVE "WWI_UserData" TO "/var/opt/mssql/data/WideWorldImporters_userdata.ndf", MOVE "WWI_Log" TO "/var/opt/mssql/data/WideWorldImporters.ldf", MOVE "WWI_InMemory_Data_1" TO "/var/opt/mssql/data/WideWorldImporters_InMemory_Data_1"'
254254
```
255255

256-
You should see an output similar to the following:
256+
The results should look similar to the following output:
257257

258258
```output
259259
Processed 1464 pages for database 'WideWorldImporters', file 'WWI_Primary' on file 1.
@@ -286,7 +286,7 @@ The backup file is now located inside the container. Before restoring the backup
286286
Run the following query to display a list of database names in your container:
287287

288288
```bash
289-
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
289+
sudo docker exec -it sql1 /opt/mssql-tools18/bin/sqlcmd \
290290
-S localhost -U sa -P '<new-password>' \
291291
-Q 'SELECT name FROM sys.databases'
292292
```
@@ -300,7 +300,7 @@ Follow these steps to make a change in the database.
300300
1. Run a query to view the top 10 items in the `Warehouse.StockItems` table.
301301

302302
```bash
303-
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
303+
sudo docker exec -it sql1 /opt/mssql-tools18/bin/sqlcmd \
304304
-S localhost -U sa -P '<new-password>' \
305305
-Q 'SELECT TOP 10 StockItemID, StockItemName FROM WideWorldImporters.Warehouse.StockItems ORDER BY StockItemID'
306306
```
@@ -325,7 +325,7 @@ Follow these steps to make a change in the database.
325325
1. Update the description of the first item with the following `UPDATE` statement:
326326

327327
```bash
328-
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
328+
sudo docker exec -it sql1 /opt/mssql-tools18/bin/sqlcmd \
329329
-S localhost -U sa -P '<new-password>' \
330330
-Q 'UPDATE WideWorldImporters.Warehouse.StockItems SET StockItemName="USB missile launcher (Dark Green)" WHERE StockItemID=1; SELECT StockItemID, StockItemName FROM WideWorldImporters.Warehouse.StockItems WHERE StockItemID=1'
331331
```
@@ -341,17 +341,17 @@ Follow these steps to make a change in the database.
341341

342342
### Create a new backup
343343

344-
After you've restored your database into a container, you might also want to regularly create database backups inside the running container. The steps follow a similar pattern to the previous steps but in reverse.
344+
After you restore your database into a container, you might also want to regularly create database backups inside the running container. The steps follow a similar pattern to the previous steps but in reverse.
345345

346346
1. Use the `BACKUP DATABASE` Transact-SQL command to create a database backup in the container. This tutorial creates a new backup file, `wwi_2.bak`, in the previously created `/var/opt/mssql/backup` directory.
347347

348348
```bash
349-
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
349+
sudo docker exec -it sql1 /opt/mssql-tools18/bin/sqlcmd \
350350
-S localhost -U sa -P '<new-password>' \
351351
-Q "BACKUP DATABASE [WideWorldImporters] TO DISK = N'/var/opt/mssql/backup/wwi_2.bak' WITH NOFORMAT, NOINIT, NAME = 'WideWorldImporters-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
352352
```
353353

354-
You should see output similar to the following:
354+
The results should look similar to the following output:
355355

356356
```output
357357
10 percent processed.
@@ -442,7 +442,7 @@ In addition to taking database backups for protecting your data, you can also us
442442
1. The Wide World Importers database is now in the new container. Run a query to verify the previous change you made.
443443

444444
```bash
445-
sudo docker exec -it sql2 /opt/mssql-tools/bin/sqlcmd \
445+
sudo docker exec -it sql2 /opt/mssql-tools18/bin/sqlcmd \
446446
-S localhost -U sa -P '<new-password>' \
447447
-Q 'SELECT StockItemID, StockItemName FROM WideWorldImporters.Warehouse.StockItems WHERE StockItemID=1'
448448
```
@@ -476,7 +476,7 @@ In addition to taking database backups for protecting your data, you can also us
476476
1. The Wide World Importers database is now in the new container. Run a query to verify the previous change you made.
477477

478478
```bash
479-
sudo docker exec -it sql2 /opt/mssql-tools/bin/sqlcmd \
479+
sudo docker exec -it sql2 /opt/mssql-tools18/bin/sqlcmd \
480480
-S localhost -U sa -P '<new-password>' \
481481
-Q 'SELECT StockItemID, StockItemName FROM WideWorldImporters.Warehouse.StockItems WHERE StockItemID=1'
482482
```
@@ -540,15 +540,15 @@ Follow these steps to make a change in the database.
540540
541541
### Create a new backup
542542
543-
After you've restored your database into a container, you might also want to regularly create database backups inside the running container. The steps follow a similar pattern to the previous steps but in reverse.
543+
After you restore your database into a container, you might also want to regularly create database backups inside the running container. The steps follow a similar pattern to the previous steps but in reverse.
544544
545545
1. Use the `BACKUP DATABASE` Transact-SQL command to create a database backup in the container. This tutorial creates a new backup file, `wwi_2.bak` in the `/var/opt/mssql/backup` directory.
546546
547547
```bash
548548
sqlcmd -Q "BACKUP DATABASE [WideWorldImporters-Full] TO DISK = N'/var/opt/mssql/backup/wwi_2.bak' WITH NOFORMAT, NOINIT, NAME = 'WideWorldImporters-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
549549
```
550550
551-
You should see output similar to the following:
551+
The results should look similar to the following output:
552552
553553
```output
554554
10 percent processed.
@@ -571,9 +571,9 @@ After you've restored your database into a container, you might also want to reg
571571
572572
### Clean up
573573
574-
Now that the backup has been copied off the container, it can be cleaned up. The following steps completely remove the `sql1` container.
574+
Now that the backup is copied off the container, it can be cleaned up. The following steps completely remove the `sql1` container.
575575
576-
1. Remove the container. **sqlcmd** has built-in safeguards to prevent deleting a container that is in use. The way it determines if a container is still in use is whether it has any user databases. For production scenarios, you should delete user databases individually after verifying they are no long in use. For development/testing we can use the `--force` parameter to delete the container without deleting the user database.
576+
1. Remove the container. **sqlcmd** has built-in safeguards to prevent deleting a container that is in use. The way it determines if a container is still in use is whether it has any user databases. For production scenarios, you should delete user databases individually after verifying they're no long in use. For development/testing, you can use the `--force` parameter to delete the container without deleting the user database.
577577

578578
```bash
579579
sqlcmd delete --force

0 commit comments

Comments
 (0)