本文共 9754 字,大约阅读时间需要 32 分钟。
In this 18th article of the series, we will discuss the concepts of database backup-and-restore of SQL Server Docker containers using Azure Data Studio. Before proceeding, you need to have Docker engine installed and Azure Data Studio configured on your host machine.
在本系列的第 18篇文章中,我们将讨论使用Azure Data Studio进行SQL Server Docker容器的数据库备份和还原的概念。 在继续之前,您需要在主机上安装Docker引擎并配置Azure Data Studio。
This article covers the following topics:
本文涵盖以下主题:
Microsoft release of new light-weight cross-platform GUI tool into the SQL Server Management umbrella is called Azure Data Studio. Azure Data Studio is a cross-platform graphical user interface for working with SQL Server instances.
Microsoft在SQL Server管理工具中发布了新的轻量级跨平台GUI工具,称为Azure Data Studio。 Azure Data Studio是一个跨平台的图形用户界面,用于处理SQL Server实例。
Feature Highlights
功能亮点
The list continues…
清单还在继续…
I would recommend go ahead and download the version for your platform of choice to see how it works.
我建议继续下载适合您所选平台的版本,以了解其工作原理。
Docker carves up a running system into small containers, each of which is sealed, segmented, with its own programs and isolated from anything else. Docker’s mission is to build, ship, and run distributed applications across anywhere and on any platform. It can be on your Local Laptop, or on the Cloud, or On-premise servers
Docker将一个正在运行的系统分割成多个小容器,每个小容器都用自己的程序密封,分段,并与其他任何对象隔离。 Docker的使命是跨任何地方,在任何平台上构建,交付和运行分布式应用程序。 它可以在您的本地笔记本电脑上,也可以在云上,或在本地服务器上
Let’s start Azure Data Studio and open the interactive terminal.
让我们启动Azure Data Studio并打开交互式终端。
First, let’s download the latest SQL Server 2017 extract from the docker hub. To extract, run the docker pull command with the SQL Server 2017 image-tag. It is also possible to extract the specific Docker container images from the docker hub repository. To get the latest SQL image, type in the word “latest”, the tag, after the colon. This gives us the most recent SQL Server 2017 image.
首先,让我们从Docker中心下载最新SQL Server 2017摘录。 要提取数据,请运行带有SQL Server 2017 image-tag的docker pull命令 。 还可以从Docker Hub存储库中提取特定的Docker容器映像。 要获取最新SQL映像,请在冒号后键入单词“ latest”(即标记)。 这为我们提供了最新SQL Server 2017映像。
[root@localhost thanvitha]# docker pull microsoft/mssql-server-linux:latest
Now, run the docker image using docker run command.
现在,使用docker run命令运行docker映像。
[root@localhost thanvitha]# docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=thanVitha@20151' -p 1401:1433 --name SQLOpsBackupDemo -d microsoft/mssql-server-linux:latest
The SQL Instance is ready to accept the connections. Next, to connect to the SQL Instance, click on the Server icon on the left corner of the window.
SQL实例已准备就绪,可以接受连接。 接下来,要连接到SQL实例,请单击窗口左上角的“服务器”图标。
Add the connection details
添加连接详细信息
Next, follow the below steps for backing up the databases
接下来,请按照以下步骤备份数据库
To accomplish the backup task, right-click the database and select databases manage window.
要完成备份任务,请右键单击数据库,然后选择“ 数据库管理”窗口。
For instance, right-click on SQLShackDemo database and choose manage. In the database dashboard pane, we have some useful information including the current recovery model, the last time backups were performed on the database and the log backup, and the database’s owner account
例如,右键单击SQLShackDemo数据库,然后选择manage 。 在数据库仪表板窗格中,我们提供了一些有用的信息,包括当前的恢复模型,上次对数据库和日志备份执行备份的时间以及数据库的所有者帐户
Press Backup button to initiate the backup task.
按“备份”按钮启动备份任务。
Now, you can see, the sidebar is changed to the task-history view on the left. You can check the statuses of the backup job here.
现在,您可以看到侧边栏更改为左侧的任务历史视图。 您可以在此处检查备份作业的状态。
[root@localhost thanvitha]# docker exec -it SQLOpsBackupDemo bash root@cc8f1beae1e1:/# ls -l /var/opt/mssql/data/*.bak-rw-r-----. 1 root root 434176 May 25 14:26 /var/opt/mssql/data/SQLShackDemo-2018525-10-24-39.bak
Now, let’s dig into the second part of the process.
现在,让我们深入研究该过程的第二部分。
To perform database restore, I will be instantiating a new SQL instance SQLOpRestoreDemo using the following docker run command.
为了执行数据库还原,我将使用以下docker run命令实例化一个新SQL实例SQLOpRestoreDemo 。
[root@localhost thanvitha]# docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=thanVitha@2015' -p 1402:1433 --name SQLOpRestoreDemo -d microsoft/mssql-server-linux:latest
Let’s copy the backup file to host machine by navigating to a backup file directory. Now, copy the backup file from the host machine to the other SQL docker container using the following docker cp command.
让我们通过导航到备份文件目录将备份文件复制到主机。 现在,使用以下docker cp命令将备份文件从主机复制到另一个SQL docker容器。
[root@localhost thanvitha]# docker cp SQLOpsBackupDemo:/var/opt/mssql/data/SQLShackDemo-2018525-10-24-39.bak /tmp [root@localhost thanvitha]# docker cp /tmp/SQLShackDemo-2018525-10-24-39.bak SQLOpRestoreDemo:/var/opt/mssql/data/
Now, connect to the SQL instance by entering the required details. Here, you can see that IP address followed by a port number is entered to connect to an instance.
现在,通过输入所需的详细信息连接到SQL实例。 在这里,您可以看到输入IP地址和端口号以连接到实例。
Next, click the restore icon on the dashboard.
接下来,单击仪表板上的还原图标。
In the restore database screen, select the general section; choose the backup file by navigating to the backup directory.
在还原数据库屏幕中,选择常规部分; 通过导航到备份目录来选择备份文件。
In the files tab, specify the location to relocate the data and log files.
在文件选项卡中,指定要重新定位数据和日志文件的位置。
In the options tab, choose the overwrite options.
在选项选项卡中,选择覆盖选项。
You can also generate a script and run it or just press the restore button to complete the restore process.
您还可以生成一个脚本并运行它,或者只需按还原按钮即可完成还原过程。
The task history appears on the right part of the Azure Data Studio. This concludes that the database SQLShackDemo restored successfully.
任务历史记录显示在Azure Data Studio的右侧。 得出结论,数据库SQLShackDemo已成功还原。
You can also browse the SQL instance to verify the database.
您还可以浏览SQL实例以验证数据库。
That’s all for now…
目前为止就这样了…
Thus far, we see the step by step instructions to initiate a database backup and restore SQL Docker containers using Azure Data Studio interface.
到目前为止,我们看到了逐步说明以使用Azure Data Studio界面启动数据库备份和还原SQL Docker容器。
We can say that it’s a light-weight version of SQL Server Management Studio (SSMS). The interface is very simple, straight-forward and self-explanatory. It is built with several options and is very well laid-out to walk you through common procedures.
我们可以说它是SQL Server Management Studio(SSMS)的轻量级版本。 界面非常简单,简单明了。 它具有多个选项,并且布局合理,可引导您完成常见的过程。
Backup and Restore operations with SQL Server 2017 on Docker containers using Azure Data Studio |
使用Azure Data Studio在Docker容器上使用SQL Server 2017进行备份和还原操作 |
翻译自:
转载地址:http://ewnwd.baihongyu.com/