sql azure 语法

In the last chapter, we explained how to create a Microsoft Azure Account and how to have a Microsoft Azure Portal.

在上一章中 ,我们说明了如何创建Microsoft Azure帐户以及如何具有Microsoft Azure门户。

This time, we will show how to backup our SQL Server Databases to a Microsoft Azure. We are assuming that you already have an Azure account.

这次,我们将展示如何将SQL Server数据库备份到Microsoft Azure。 我们假设您已经有一个Azure帐户。

介绍 ( Introduction )

Microsoft Azure stores your information with redundancy on the web. It is a safe and secure environment and simplifies your administrative tasks.

Microsoft Azure将您的信息以冗余方式存储在Web上。 这是一个安全的环境,可简化您的管理任务。

入门 ( Getting Started )

There are two main steps to backup your database in Microsoft Azure:

在Microsoft Azure中备份数据库有两个主要步骤:

  1. Create a Storage with a container in the Microsoft Azure portal.在Microsoft Azure门户中使用容器创建存储。
  2. Backup your local Database to that container (you will need a credential to connect to the Storage).将本地数据库备份到该容器(您需要凭据才能连接到存储)。

在Microsoft Azure中创建存储和容器 ( Create a Storage and a Container in Microsoft Azure )

The first step to backup in Azure is to create a storage.

在Azure中进行备份的第一步是创建一个存储。

First, sign in to the Microsoft Azure Portal:

首先,登录到Microsoft Azure门户:

https://manage.windowsazure.com

https://manage.windowsazure.com

Click on the Storage link to create a new storage.

单击存储链接以创建新的存储。

Figure 2. The storage in Azure

图2. Azure中的存储

Create a new storage using the new link.

使用新链接创建一个新的存储。

Figure 3. New Storage creation

图3.创建新存储

Use the Quick create option to create the new storage.

使用快速创建选项创建新的存储。

Figure 4. Quick storage creation

图4.快速创建存储

For the URL, you can use any name if it does not already exist.

对于URL,可以使用任何尚不存在的名称。

Location/Affinity group, lets you select where you want to store the primary data. It is recommended to select a location closer to your current region. The options available when this article was created were:

位置/亲和力组,使您可以选择要存储主要数据的位置。 建议选择一个靠近您当前区域的位置。 创建本文时可用的选项为:

  • West US美国西部
  • East US 2美国东部2
  • Central US美国中部
  • South Central US美国中南部
  • West Europe西欧
  • East US美国东部
  • Southeast Asia东南亚
  • East Asia东亚
  • Japan West日本西部
  • Japan East东日本

The other options available are:

其他可用选项包括:

  • Locally redundant storage stores and maintains three copies of your data in a single facility and a single region.本地冗余存储将数据的三个副本存储并维护在一个设施和一个区域中。
  • Geo-Redundant is the default and recommended option. This option lets you create six replicas of your data 3 in your local region and three in other region far away from the other replica. 地理冗余是默认和推荐的选项。 通过此选项,您可以在本地区域中创建六个数据副本3,并在远离其他副本的其他区域中创建三个副本。
  • Read access geo-redundant creates replicas in a primary region and secondary read-only replica in a second region. In case that the primary replica fails, the secondary replica can be used with read-only permissions.读取访问地理冗余在主区域中创建副本,在第二区域中创建辅助只读副本。 如果主副本发生故障,则可以以只读权限使用辅助副本。
  • Zone-Redundant storage lets you store 2-3 replicas in the same region or two different regions.区域冗余存储使您可以在同一区域或两个不同区域中存储2-3个副本。

Figure 5. Storage options

图5.存储选项

If everything is OK, a new storage will be created. Click on the sqlshack link just created.

如果一切正常,将创建一个新的存储。 单击刚刚创建的sqlshack链接。

Figure 6. The sqlshack storage created.

图6.创建的sqlshack存储。

Click the containers link.

单击容器链接。

Figure 7. The containers

图7.容器

Click the Create a container option.

单击创建容器选项。

Figure 8. Creating containers

图8.创建容器

Add a name to the container.

在容器中添加一个名称。

Figure 9. New container information

图9.新容器信息

A new container will be created.

将创建一个新的容器。

Figure 10. The container URL.

图10.容器URL。

Return to the storage section and click the manage keys option.

返回到存储部分,然后单击管理密钥选项。

Figure 11. Manage keys option

图11.管理密钥选项

The Manage Access Keys are used to connect to SQL Azure. The use will be explained later.

管理访问密钥用于连接到SQL Azure。 用法将在后面说明。

Figure 12 Azure Storage Access keys

图12 Azure存储访问键

SSMS中SQL Server备份 ( SQL Server Backup in SSMS )

We will create a Credential first to connect to Azure.

我们将首先创建一个凭据以连接到Azure。

Figure 13 New Credential

图13新凭证

The identity should be the storage name used in figure 5, the Password and Confirm password are the primary keys used in figure 12. Use the primary key as a password and in the confirm password textbox.

身份应该是图5中使用的存储名称,密码和确认密码是图12中使用的主键。使用主键作为密码,并在确认密码文本框中。

Figure 14 Credential information

图14凭证信息

If you prefer you prefer the T-SQL, you can use the following sentences:

如果您更喜欢T-SQL,则可以使用以下语句:


CREATE CREDENTIAL [sqlshackcredential]
WITH IDENTITY = N'sqlshack',
SECRET = N'asssssddddddffqqq'
GO

Now, backup a local database.

现在,备份本地数据库。

Figure 15 Back Up Database

图15备份数据库

In the Back up to option, select URL. In file name, you can write any name or keep the default values. In SQL credential, select the credential created in figure 14. In azure storage container, use the container created in figure 9. Finally, for the URL prefix, used the URL container used in the figure 10. Once this option are set, create the backup.

在“备份到”选项中,选择“ URL”。 在文件名中,您可以输入任何名称或保留默认值。 在SQL凭证中,选择在图14中创建的凭证。在Azure存储容器中,使用在图9中创建的容器。最后,对于URL前缀,使用在图10中使用的URL容器。一旦设置了此选项,请创建备份。

Figure 16. Destination information

图16.目的地信息

If you prefer the T-SQL, you can use the following sentences:

如果您更喜欢T-SQL,则可以使用以下语句:


BACKUP DATABASE [d1]
TO  URL = N'https://sqlshack.blob.core.windows.net/sqlshackcontainer/d1_backup_2015_01_19_171804.bak'
WITH  CREDENTIAL = N'sqlshackcredential' , NOFORMAT, NOINIT,
NAME = N'd1-Full Database Backup', NOSKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO

If everything is OK, you will be able to see the backup created in the Microsoft Azure portal.

如果一切正常,您将能够看到在Microsoft Azure门户中创建的备份。

Figure 17. The backup created in Microsoft Azure

图17.在Microsoft Azure中创建的备份

测试备份 ( Testing the backup )

In order to test, the backup created, let’s test the backup.

为了测试,创建了备份,让我们测试备份。

Delete the database to test the backup.

删除数据库以测试备份。

Figure 18. Dropping a Database for testing purposes

图18.删除数据库以进行测试

If you prefer the T-SQL, you can use the following sentences:

如果您更喜欢T-SQL,则可以使用以下语句:


DROP DATABASE D1

Select the Restore Database option.

选择还原数据库选项。

Figure 19. Restoring options.

图19.恢复选项。

Select the Device option and press the ellipsis button.

选择设备选项,然后按省略号按钮。

Figure 20. Restoring options

图20.恢复选项

In the Backup media type, select the URL option and press the Add Button.

在“备份”媒体类型中,选择“ URL”选项,然后按“添加”按钮。

Figure 21. Restoring to URL.

图21.恢复到URL。

In the Storage Account select the Storage name used in figure 5, in access keys, select the access key of the figure 12. Keep the use of HTTPS option. In the select an existing credential, use the credential created in figure 14 and press Connect.

在“存储帐户”中,选择图5中使用的存储名称,在访问键中,选择图12的访问键。继续使用HTTPS选项。 在选择一个现有的凭证中,使用图14中创建的凭证,然后按Connect。

Figure 22. URL an Credential settings to restore a database

图22. URL a Credential设置以还原数据库

In Containers, select the container created in figure 9 and then on the right pane, select the backup created in figure 17.

在“容器”中,选择在图9中创建的容器,然后在右窗格中,选择在图17中创建的备份。

Figure 23. Selecting the backup from Microsoft Azure.

图23.从Microsoft Azure选择备份。

Once done, create the backup. The first phase a recovering plan will be created. The restore plan will retrieve all the information related to the backup in the Azure Portal.

完成后,创建备份。 第一阶段将创建恢复计划。 还原计划将在Azure门户中检索与备份有关的所有信息。

Figure 24. Creating the restore plan.

图24.创建还原计划。

The second phase will be the database restoring Process, which will restore the information from the backup Stored in the Azure Portal.

第二阶段将是数据库还原过程,该过程将从存储在Azure门户中的备份还原信息。

Figure 25. Restoring the database.

图25.还原数据库。

You can also restore the database using T-SQL sentences:

您还可以使用T-SQL语句还原数据库:


USE [master]
RESTORE DATABASE [d1]
FROM  URL = N'https://sqlshack.blob.core.windows.net/sqlshackcontainer/d1_backup_2015_01_19_140352.bak'
WITH  CREDENTIAL = N'sqlshackcredential' ,  FILE = 1,  NOUNLOAD,  STATS = 5GO

If everything is OK, you will be able to see the database restored.

如果一切正常,您将能够看到数据库已还原。

Figure 26. The local SQL Server Database restored.

图26. 恢复的本地SQL Server数据库。

最终建议 ( Final Recommendations )

Your internet connectivity is critical if you want to work with Microsoft Azure. If your internet connectivity is not trustable, your backup and recovery plan will not be trustable either. The same for the Internet Speed. If your Internet Connectivity is not fast, restoring a 32 GB database will take hours. Test your Database in a testing environment before taking a decision to migrate to Azure.

如果要使用Microsoft Azure,则Internet连接至关重要。 如果您的Internet连接不可靠,则备份和恢复计划也将不可靠。 互联网速度相同。 如果您的Internet连接速度不快,则还原32 GB数据库将花费数小时。 在决定迁移到Azure之前,请在测试环境中测试数据库。

结论 ( Conclusion )

In this article, we show how to create a storage in Microsoft Azure, how to create a container, how to backup a local SQL Server Database to that storage and finally how to restore the database stored from the Microsoft Azure Storage.

在本文中,我们将展示如何在Microsoft Azure中创建存储,如何创建容器,如何将本地SQL Server数据库备份到该存储以及最后如何从Microsoft Azure存储还原存储的数据库。

翻译自: https://www.sqlshack.com/backup-sql-server-databases-microsoft-azure/

sql azure 语法

sql azure 语法_如何将SQL Server数据库备份到Microsoft Azure相关推荐

  1. sql azure 语法_如何在SQL 2016中使用Azure Key Vault使用AlwaysOn配置TDE数据库

    sql azure 语法 One of the recent tasks I undertook on configuring Transparent Data encryption (TDE) us ...

  2. sql azure 语法_如何将SQL数据迁移到Azure Cosmos DB

    sql azure 语法 In this article, I have explained the step by step process of migrating data from SQL S ...

  3. sql azure 语法_如何将内部SQL Server数据库迁移到Azure

    sql azure 语法 Lately, database administrators often hear the question "have you tried Azure?&quo ...

  4. sql azure 语法_使用Azure Data Studio从SQL Server数据创建图表

    sql azure 语法 In this article, we will explore charts in an Azure Data Studio using data stored in SQ ...

  5. sql azure 语法_将SQL工作负载迁移到Microsoft Azure:服务选择

    sql azure 语法 In the previous article, Migrating SQL workloads to Microsoft Azure: Planning the jump, ...

  6. sql azure 语法_深入了解Azure Data Studio:扩展和Azure SQL DB开发

    sql azure 语法 In the previous articles listed below, we went through the Azure Data Studio tool, star ...

  7. DBATools PowerShell SQL Server数据库备份命令

    In my earlier PowerShell SQL Server article, SQL Database Backups using PowerShell Module – DBATools ...

  8. SQL Server数据库备份和还原报告

    In the previous articles, we discussed several ways of taking backup and testing the restore process ...

  9. SQL Server 数据库备份

    SQL Server 数据库备份 原文 http://www.cnblogs.com/ynbt/archive/2013/04/04/2999642.html 备份数据库是指对数据库或事务日志进行复制 ...

最新文章

  1. “治沙女杰”殷玉珍:和沙漠较量的女人
  2. HTTP 500 服务器内部错误的解决方法
  3. mpstat 命令查看所有CPU核信息
  4. 基于Boost::beast模块的无栈协程http服务器
  5. dsoFramer 的原代码
  6. 【51Nod - 1215 】数组的宽度 (单调栈 或 分治 或 单调队列,算贡献,需去重)
  7. PHP配置环境中开启GD库
  8. 关于TransactionScope出错:“与基础事务管理器的通信失败”的解决方法
  9. TF-layers.MaxPooling1D
  10. vue push 无效_深入浅出Vue响应式原理
  11. 根据经纬度查询位置百度api
  12. 解决:kubeadm init K8S初始化报错02
  13. Dubbo监控中心Dubbo-admin安装
  14. CISP-PTE是什么证书,CISP-PTE证书有什么用?
  15. Elesticsearch基础
  16. Web应用怎样获取Access Token?
  17. 关于开学第一周的总结
  18. Mysql ——区、段、表空间 、碎片区
  19. 东华大学计算机学院推免生面试难吗,东华大学接收推免生复试与录取办法
  20. 【环信IM集成教程】iOS端收到离线消息显示设置

热门文章

  1. lateX 编译中文_LaTeX | 为学术论文排版而生【入门篇】
  2. 不良事件总结怎么写_护理不良事件总结分析.doc
  3. ElasticSearch之 控制相关度原理讲解
  4. 2015年创业中遇到的技术问题:21-30
  5. Android之提交数据到服务端方法简单封装
  6. 动易Ajax登陆调用
  7. 就9.5面试做个小结
  8. JavaScript学习(十二)—removeAttribute方法、hasAttribute方法、createAttribute方法以及setAttributeNode方法
  9. 活动地推怎么做最有效?
  10. 理财最低持有天数是什么意思?