使用 SSMS 还原数据库备份Restore a Database Backup Using SSMS

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions)

本主题阐释如何使用 SQL Server Management Studio 还原完整的数据库备份。This topic explains how to restore a full database backup using SQL Server Management Studio.

重要说明!Important!

在完整恢复模式或大容量日志恢复模式下,可能需要先备份活动事务日志(称为 日志尾部),然后才能还原数据库。Before you can restore a database under the full or bulk-logged recovery model, you may need to back up the active transaction log (known as tail of the log. 有关详细信息,请参阅 备份事务日志 (SQL Server)数据库还原到一个新位置并且可以选择重命名该数据库。For more information, see Back Up a Transaction Log (SQL Server).

从其他实例还原数据库时,请考虑 当数据库在其他服务器实例上可用时管理元数据 (SQL Server)中的信息。When restoring a database from another instance, consider the information from Manage Metadata When Making a Database Available on Another Server Instance (SQL Server).

若要还原加密数据库,你需要有用于加密该数据库的证书或非对称密钥的访问权限。To restore an encrypted database, you need access to the certificate or asymmetric key used to encrypt that database. 如果没有证书或非对称密钥,数据库将无法还原。Without the certificate or asymmetric key, you cannot restore that database. 如果需要保存备份,就必须保留用于加密数据库加密密钥的证书。You must retain the certificate used to encrypt the database encryption key for as long as you need to save the backup. 有关详细信息,请参阅 SQL Server Certificates and Asymmetric KeysFor more information, see SQL Server Certificates and Asymmetric Keys.

如果将较旧版本的数据库还原到 SQL Server 2019 (15.x)SQL Server 2019 (15.x),则该数据库将自动升级到 SQL Server 2019 (15.x)SQL Server 2019 (15.x)If you restore an older version database to SQL Server 2019 (15.x)SQL Server 2019 (15.x), that database will automatically upgrade to SQL Server 2019 (15.x)SQL Server 2019 (15.x). 这将阻止数据库被旧版本的 数据库引擎Database Engine 使用。This precludes the database from being used with an older version of the 数据库引擎Database Engine. 但是,这与元数据升级相关,不会影响数据库兼容性级别However, this relates to metadata upgrade and does not affect the database compatibility level. 如果升级前用户数据库的兼容级别为 100 或更高,升级后将保持相应级别。If the compatibility level of a user database is 100 or higher before upgrade, it remains the same after upgrade. 如果升级前兼容级别为 90,则在升级后的数据库中,兼容级别将设置为 100,该级别为 SQL Server 2019 (15.x)SQL Server 2019 (15.x)支持的最低兼容级别。If the compatibility level is 90 before upgrade, in the upgraded database, the compatibility level is set to 100, which is the lowest supported compatibility level in SQL Server 2019 (15.x)SQL Server 2019 (15.x). 有关详细信息,请参阅 ALTER DATABASE 兼容级别 (Transact-SQL)For more information, see ALTER DATABASE Compatibility Level (Transact-SQL).

通常,该数据库将立即可用。Typically, the database becomes available immediately. 但是,如果 SQL Server 2005 (9.x)SQL Server 2005 (9.x) 数据库具有全文检索,则升级过程将导入、重置或重新生成它们,具体取决于 全文升级选项 服务器属性的设置。However, if a SQL Server 2005 (9.x)SQL Server 2005 (9.x) database has full-text indexes, the upgrade process either imports, resets, or rebuilds the indexes, depending on the setting of the Full-Text Upgrade Option server property. 如果将升级选项设置为“导入” 或“重新生成” ,在升级过程中将无法使用全文检索。If you set upgrade option to Import or Rebuild, the full-text indexes will be unavailable during the upgrade. 导入可能需要数小时,而重新生成所需的时间最多时可能十倍于此,具体取决于要编制索引的数据量。Depending on the amount of data being indexed, importing can take several hours; rebuilding will take up to ten times longer.

当升级选项设置为“导入” 时,如果全文目录不可用,将重新生成关联的全文检索。When you set upgrade option to Import, if a full-text catalog is not available, the associated full-text indexes are rebuilt. 有关查看或更改“全文升级选项” 属性设置的信息,请参阅管理和监视服务器实例的全文搜索For information about viewing or changing the setting of the Full-Text Upgrade Option property, see Manage and Monitor Full-Text Search for a Server Instance.

有关从 Microsoft Azure Blob 存储服务还原 SQL Server 的信息,请参阅《SQL Server Backup and Restore with Microsoft Azure Blob Storage Service》(使用 Microsoft Azure Blob 存储服务进行 SQL Server 备份和还原)。For information on SQL Server restore from the Microsoft Azure Blob storage service, see SQL Server Backup and Restore with Microsoft Azure Blob Storage Service.

示例Examples

A.A. 还原完整的数据库备份Restore a full database backup

  1. “对象资源管理器” 中,连接到 SQL Server 数据库引擎SQL Server Database Engine 的实例,然后展开该实例。In Object Explorer, connect to an instance of the SQL Server 数据库引擎SQL Server Database Engine and then expand that instance.

  2. 右键单击“数据库” ,然后选择“还原数据库...” Right-click Databases and select Restore Database...

  3. “常规” 页上,使用 “源” 部分指定要还原的备份集的源和位置。On the General page, use the Source section to specify the source and location of the backup sets to restore. 选择以下选项之一:Select one of the following options:

    • DatabaseDatabase

      从下拉列表中选择要还原的数据库。Select the database to restore from the drop-down list. 此列表仅包含已根据 msdb 备份历史记录进行备份的数据库。The list contains only databases that have been backed up according to the msdb backup history.

      备注

      如果备份是从另一台服务器执行的,则目标服务器不具有指定数据库的备份历史记录信息。If the backup is taken from a different server, the destination server will not have the backup history information for the specified database. 这种情况下,请选择 “设备” 以手动指定要还原的文件或设备。In this case, select Device to manually specify the file or device to restore.

    • 设备Device

      单击“浏览”按钮 ( ... ) 以打开“选择备份设备” 对话框。Click the browse (...) button to open the Select backup devices dialog box.

      • 选择备份设备 对话框Select backup devices dialog box

        备份介质类型Backup media type
        从“备份介质类型”下拉列表中选择一个介质类型。 Select a media type from the Backup media type drop-down list. 注意:只有在计算机上装有磁带机时,才会显示 “磁带” 选项,只有至少存在一个备份设备时,才会显示 “备份设备” 选项。Note: The Tape option appears only if a tape drive is mounted on the computer, and the Backup Device option appears, only if at least one backup device exists.

        添加Add
        根据在“备份介质类型”下拉列表中选择的介质类型,单击“添加”将打开下列对话框之一。 Depending on the type of media you select from the Backup media type drop-down list, clicking Add opens one of the following dialog boxes. (如果“备份介质”列表框中的列表已满,则“添加”按钮不可用。) (If the list in the Backup media list box is full, the Add button is unavailable.)

        介质类型Media type 对话框Dialog box 说明Description
        FileFile 定位备份文件Locate Backup File 在此对话框中,您可以从树中选择一个本地文件,或使用完全限定的通用命名约定 (UNC) 名称指定一个远程文件。In this dialog box, you can select a local file from the tree or specify a remote file using its fully qualified universal naming convention (UNC) name. 有关详细信息,请参阅 备份设备 (SQL Server)For more information, see Backup Devices (SQL Server).
        设备Device 选择备份设备Select Backup Device 在此对话框中,您可以从服务器实例中定义的逻辑备份设备列表中进行选择。In this dialog box, you can select from a list of the logical backup devices defined on the server instance.
        磁带Tape 选择备份磁带Select Backup Tape 在此对话框中,您可以从与运行 SQL ServerSQL Server实例的计算机物理连接的磁带机列表中进行选择。In this dialog box, you can select from a list of the tape drives that are physically connected to the computer running the instance of SQL ServerSQL Server.
        URLURL 选择备份文件位置Select a Backup File Location 在该对话框中可以选择现有 SQL Server 凭据/Azure 存储容器、添加具有共享访问签名的新 Azure 存储容器或为现有存储容器生成共享访问签名和 SQL Server 凭据。In this dialog box, you can select an existing SQL Server credential/Azure storage container, add a new Azure storage container with a shared access signature, or generate a shared access signature and SQL Server credential for an existing storage container. 另请参阅 《Connect to a Microsoft Azure Subscription》(连接到 Microsoft Azure 订阅)。See also, Connect to a Microsoft Azure Subscription

        删除 Remove
        删除一个或多个选定的文件、磁带或逻辑备份设备。Removes one or more selected files, tapes, or logical backup devices.

        目录 Contents
        显示选定文件、磁带或逻辑备份设备的介质内容。Displays the media contents of a selected file, tape, or logical backup device. 如果介质类型为“URL”,此按钮可能不起作用。 This button may not function if the media type is URL.

        备份介质 Backup media
        列出所选介质。Lists the selected media.

        将所需设备添加到 “备份介质” 列表框后,单击 “确定” 返回到 “常规” 页。After you add the devices you want to the Backup media list box, click OK to return to the General page.

      在“源:设备:数据库”列表框中,选择应还原的数据库名称 In the Source: Device: Database list box, select the name of the database which should be restored.

      备注

      此列表仅在选择了 “设备” 时才可用。This list is only available when Device is selected. 只有在所选设备上具有备份的数据库才可用。Only databases that have backups on the selected device will be available.

  4. “目标” 部分中, “数据库” 框自动填充要还原的数据库的名称。In the Destination section, the Database box is automatically populated with the name of the database to be restored. 若要更改数据库名称,请在 “数据库” 框中输入新名称。To change the name of the database, enter the new name in the Database box.

  5. “还原到” 框中,保留默认选项 “至最近一次进行的备份” ,或者单击 “时间线” 访问 “备份时间线” 对话框以手动选择要停止恢复操作的时间点。In the Restore to box, leave the default as To the last backup taken or click on Timeline to access the Backup Timeline dialog box to manually select a point in time to stop the recovery action. 有关指定特定时间点的详细信息,请参阅 Backup TimelineFor more information on designating a specific point in time, see Backup Timeline.

  6. “要还原的备份集” 网格中,选择要还原的备份。In the Backup sets to restore grid, select the backups to restore. 此网格将显示对于指定位置可用的备份。This grid displays the backups available for the specified location. 默认情况下,系统会推荐一个恢复计划。By default, a recovery plan is suggested. 若要覆盖建议的恢复计划,可以更改网格中的选择。To override the suggested recovery plan, you can change the selections in the grid. 当取消选择某个早期备份时,将自动取消选择那些需要还原该早期备份才能进行的备份。Backups that depend on the restoration of an earlier backup are automatically deselected when the earlier backup is deselected. 有关“用于还原的备份集” 网格中的列的信息,请参阅还原数据库(“常规”页)For information about the columns in the Backup sets to restore grid, see Restore Database (General Page).

  7. 或者单击 “选择页” 窗格中的 “文件” ,以便访问 “文件” 对话框。Optionally, click Files in the Select a page pane to access the Files dialog box. 在该对话框中,您可以通过在 “将数据库文件还原为” 网格中指定每个文件的新还原目标,将数据库还原到新的位置。From here, you can restore the database to a new location by specifying a new restore destination for each file in the Restore the database files as grid. 有关该网格的详细信息,请参阅还原数据库(“文件”页)For more information about this grid, see Restore Database (Files Page).

  8. 若要查看或选择高级选项,在 “选项” 页的 “还原选项” 面板中,可以根据您的实际情况选择下列任意选项:To view or select the advanced options, on the Options page, in the Restore options panel, you can select any of the following options, if appropriate for your situation:

    1. WITH 选项(可选):WITH options (not required):
    • 覆盖现有数据库(WITH REPLACE)Overwrite the existing database (WITH REPLACE)

    • 保留复制设置(WITH KEEP_REPLICATION)Preserve the replication settings (WITH KEEP_REPLICATION)

    • 限制对还原数据库的访问(WITH RESTRICTED_USER)Restrict access to the restored database (WITH RESTRICTED_USER)

    1. “恢复状态” 框选择一个选项。Select an option for the Recovery state box. 此框确定还原操作之后的数据库状态。This box determines the state of the database after the restore operation.
    • RESTORE WITH RECOVERY 是默认行为,它通过回滚未提交的事务,使数据库处于可以使用的状态。RESTORE WITH RECOVERY is the default behavior which leaves the database ready for use by rolling back the uncommitted transactions. 无法还原其他事务日志。Additional transaction logs cannot be restored. 如果您要立即还原所有必要的备份,则选择此选项。Select this option if you are restoring all of the necessary backups now.

    • RESTORE WITH NORECOVERY 不对数据库执行任何操作,不回滚未提交的事务。RESTORE WITH NORECOVERY which leaves the database non-operational, and does not roll back the uncommitted transactions. 可以还原其他事务日志。Additional transaction logs can be restored. 除非恢复数据库,否则无法使用数据库。The database cannot be used until it is recovered.

    • RESTORE WITH STANDBY 使数据库处于只读模式。RESTORE WITH STANDBY which leaves the database in read-only mode. 它撤消未提交的事务,但将撤消操作保存在备用文件中,以便能够还原恢复结果。It undoes uncommitted transactions, but saves the undo actions in a standby file so that recovery effects can be reverted.

    1. 还原前进行结尾日志备份。Take tail-log backup before restore. 并非所有还原方案都要求执行结尾日志备份。Not all restore scenarios require a tail-log backup. 有关详细信息,请参阅 《Tail-Log Backups (SQL Server)》 (结尾日志备份 (SQL Server))中的 Scenarios That Require a Tail-Log Backup(需要结尾日志备份的场景)。For more information, see Scenarios That Require a Tail-Log Backup from Tail-Log Backups (SQL Server).

    2. 如果存在与数据库的活动连接,则还原操作可能会失败。Restore operations may fail if there are active connections to the database. 选中 “关闭现有连接” 以确保关闭 Management StudioManagement Studio 和数据库之间的所有活动连接。Check the Close existing connections option to ensure that all active connections between Management StudioManagement Studio and the database are closed. 此复选框可在执行还原操作之前将数据库设置为单用户模式,并在该操作完成后将数据库设置为多用户模式。This check box sets the database to single user mode before performing the restore operations, and sets the database to multi-user mode when complete.

    3. 如果要在每个还原操作之间进行提示,请选择 “还原每个备份之前进行提示”Select Prompt before restoring each backup if you wish to be prompted between each restore operation. 除非数据库过大并且您要监视还原操作的状态,否则通常没有必要选中该选项。This is not usually necessary unless the database is large and you wish to monitor the status of the restore operation.

有关这些还原选项的详细信息,请参阅 还原数据库(“选项”页)),然后才能还原数据库。For more information about these restore options, see Restore Database (Options Page).

  1. 单击“确定”。 Click OK.

B.B. 在现有数据库上还原以前的磁盘备份Restore an earlier disk backup over an existing database

下面的示例将还原 Sales 的以前的磁盘备份,并覆盖现有 Sales 数据库。The following example restores an earlier disk backup of Sales and overwrites the existing Sales database.

  1. “对象资源管理器” 中,连接到 SQL Server 数据库引擎SQL Server Database Engine 的实例,然后展开该实例。In Object Explorer, connect to an instance of the SQL Server 数据库引擎SQL Server Database Engine and then expand that instance.

  2. 右键单击“数据库” ,然后选择“还原数据库...” Right-click Databases and select Restore Database...

  3. 在“常规” 页上,在“源” 部分下选择“设备” 。On the General page, select Device under the Source section.

  4. 单击“浏览”按钮 ( ... ) 以打开“选择备份设备” 对话框。Click the browse (...) button to open the Select backup devices dialog box. 单击“添加” 并导航到你的备份。Click Add and navigate to your backup. 在选择你的磁盘备份文件之后单击“确定” 。Click OK after you have selected your disk backup file(s).

  5. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.

  6. 在“选择页”窗格中单击“选项”。 Click Options in the Select a page pane.

  7. 在“还原选项”部分中,选择“覆盖现有数据库 (WITH REPLACE)”。 Under the Restore options section, check Overwrite the existing database (WITH REPLACE).

    备注

    未选中此选项可能会导致以下错误消息:“System.Data.SqlClient.SqlError:备份集中的数据库备份与现有的“Sales”数据库不同。Not checking this option may result in the following error message: "System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing 'Sales' database. (Microsoft.SqlServer.SmoExtended)”(Microsoft.SqlServer.SmoExtended)"

  8. 在“结尾日志备份” 部分中,取消选中“还原前执行结尾日志备份” 。Under the Tail-log backup section, uncheck Take tail-log backup before restore.

    备注

    并非所有还原方案都要求执行结尾日志备份。Not all restore scenarios require a tail-log backup. 如果恢复点包含在较早的日志备份中,则无需结尾日志备份。You do not need a tail-log backup if the recovery point is contained in an earlier log backup. 此外,如果您准备移动或替换(覆盖)数据库,并且在最新备份后不需要将该数据库还原到某一时间点,则不需要结尾日志备份。Also, a tail-log backup is unnecessary if you are moving or replacing (overwriting) a database and do not need to restore it to a point of time after its most recent backup. 有关详细信息,请参阅 《Tail-Log Backups (SQL Server)》(结尾日志备份 (SQL Server))。For more information, see Tail-Log Backups (SQL Server).

    此选项不可用于简单恢复模式下的数据库。This option is not available for databases in the SIMPLE recovery model.

  9. 在“服务器连接” 部分,选中“关闭目标数据库的现有连接” 。Under the Server connections section, check Close existing connections to destination database.

    备注

    未选中此选项可能会导致以下错误消息:“System.Data.SqlClient.SqlError:因为数据库正在使用,所以无法获得对数据库的独占访问权。Not checking this option may result in the following error message: "System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use. (Microsoft.SqlServer.SmoExtended)”(Microsoft.SqlServer.SmoExtended)"

  10. 单击“确定”。 Click OK.

C.C. 使用新的数据库名称还原以前的磁盘备份,并且原始数据库仍然存在Restore an earlier disk backup with a new database name where the original database still exists

下面的示例将还原 Sales 的以前的磁盘备份,并创建名为 SalesTest的新数据库。The following example restores an earlier disk backup of Sales and creates a new database called SalesTest. 原始数据库 Sales仍存在于服务器上。The original database, Sales, still exists on the server.

  1. “对象资源管理器” 中,连接到 SQL Server 数据库引擎SQL Server Database Engine 的实例,然后展开该实例。In Object Explorer, connect to an instance of the SQL Server 数据库引擎SQL Server Database Engine and then expand that instance.

  2. 右键单击“数据库” ,然后选择“还原数据库...” Right-click Databases and select Restore Database...

  3. 在“常规” 页上,在“源” 部分下选择“设备” 。On the General page, select Device under the Source section.

  4. 单击“浏览”按钮 ( ... ) 以打开“选择备份设备” 对话框。Click the browse (...) button to open the Select backup devices dialog box. 单击“添加” 并导航到你的备份。Click Add and navigate to your backup. 在选择你的磁盘备份文件之后单击“确定” 。Click OK after you have selected your disk backup file(s).

  5. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.

  6. “目标” 部分中, “数据库” 框自动填充要还原的数据库的名称。In the Destination section, the Database box is automatically populated with the name of the database to be restored. 若要更改数据库名称,请在 “数据库” 框中输入新名称。To change the name of the database, enter the new name in the Database box.

  7. 在“选择页”窗格中单击“选项”。 Click Options in the Select a page pane.

  8. 在“结尾日志备份” 部分中,取消选中“还原前执行结尾日志备份” 。Under the Tail-log backup section, uncheck "Take tail-log backup before restore".

    重要

    如果不取消选中此选项,则会使现有的数据库中 Sales更改为还原状态。Not unchecking this option will result in the existing database, Sales, to change to the restoring state.

  9. 单击“确定”。 Click OK.

    备注

    如果收到以下错误信息:If you receive the following error message:
    “System.Data.SqlClient.SqlError:数据库“Sales”的日志结尾尚未备份。"System.Data.SqlClient.SqlError: The tail of the log for the database "Sales" has not been backed up. 如果该日志包含不希望丢失的工作,请使用 BACKUP LOG WITH NORECOVERY 备份该日志。Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. 使用 RESTORE 语句的 WITH REPLACEWITH STOPAT 子句覆盖该日志的内容。Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. (Microsoft.SqlServer.SmoExtended)”。(Microsoft.SqlServer.SmoExtended)".
    那么你可能未输入上面步骤 6 中的新数据库名称。Then you likely did not enter the new database name from Step 6, above. 还原一般会防止意外使用一个数据库覆盖另一个数据库。Restore normally prevents accidentally overwriting a database with a different database. 如果 RESTORE 语句中指定的数据库已存在于当前服务器上,并且指定的数据库系列 GUID 与备份集中记录的数据库系列 GUID 不同,则不还原该数据库。If the database specified in a RESTORE statement already exists on the current server and the specified database family GUID differs from the database family GUID recorded in the backup set, the database is not restored. 这是一项重要的安全保护措施。This is an important safeguard.

D.D. 将以前的磁盘备份还原到某个时间点Restore earlier disk backups to a point in time

下面的示例将数据库还原到它在 1:23:17 PMMay 30, 2016 的状态,并显示涉及多个日志备份的还原操作。The following example restores a database to its state as of 1:23:17 PM on May 30, 2016 and shows a restore operation that involves multiple log backups. 数据库当前不在服务器上。The database does not currently exist on the server.

  1. “对象资源管理器” 中,连接到 SQL Server 数据库引擎SQL Server Database Engine 的实例,然后展开该实例。In Object Explorer, connect to an instance of the SQL Server 数据库引擎SQL Server Database Engine and then expand that instance.
  2. 右键单击“数据库” ,然后选择“还原数据库...” Right-click Databases and select Restore Database...
  3. 在“常规” 页上,在“源” 部分下选择“设备” 。On the General page, select Device under the Source section.
  4. 单击“浏览”按钮 ( ... ) 以打开“选择备份设备” 对话框。Click the browse (...) button to open the Select backup devices dialog box. 单击“添加” 并导航到你的完整备份和所有相关事务日志备份。Click Add and navigate to your full backup and all relevant transaction log backups. 在选择你的磁盘备份文件之后单击“确定” 。Click OK after you have selected your disk backup files.
  5. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.
  6. 在“目标”部分中单击“时间线”访问“备份时间线”对话框,以手动选择要停止恢复操作的时间点。 In the Destination section, click on Timeline to access the Backup Timeline dialog box to manually select a point in time to stop the recovery action.
  7. 选择“特定的日期和时间”。 Select Specific date and time.
  8. 在下拉列表框中将“时间线间隔”更改为“小时”(可选)。 Change the Timeline interval to Hour in the drop down box (optional).
  9. 将滑块移动到所需的时间。Move the slider to the desired time.
  10. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.
  11. 单击“确定”。 Click OK.

E.E. 从 Microsoft Azure 存储服务还原备份Restore a backup from the Microsoft Azure storage service

一般步骤Common Steps

下面的两个示例执行从位于 Microsoft Azure 存储服务中的备份还原 SalesThe two examples below perform a restore of Sales from a backup located in the Microsoft Azure storage service. 存储帐户名称为 mystorageaccountThe storage Account name is mystorageaccount. 容器名称为 myfirstcontainerThe container is called myfirstcontainer. 出于简洁的目的,在此处一次列出前六个步骤,所有示例将从 步骤 7 开始。For brevity, the first six steps are listed here once and all examples will start on Step 7.

  1. 在“对象资源管理器” 中,连接到一个 SQL Server 数据库引擎实例,然后展开该实例。In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
  2. 右键单击“数据库” ,然后选择“还原数据库...” 。Right-click Databases and select Restore Database....
  3. 在“常规” 页上,在“源” 部分下选择“设备” 。On the General page, select Device under the Source section.
  4. 单击“浏览 (...)”按钮以打开“选择备份设备” 对话框。Click the browse (...) button to open the Select backup devices dialog box.
  5. 从“备份媒体类型:” 下拉列表中选择 URLSelect URL from the Backup media type: drop-down list.
  6. 单击“添加” 可打开“选择备份文件位置” 对话框。Click Add and the Select a Backup File Location dialog box opens.

E1.E1. 在现有数据库上还原条带备份,并存在共享的访问签名。Restore a striped backup over an existing database and a shared access signature exists.

已经创建具有读取、写入、删除和列表权限的存储访问策略。A stored access policy has been created with read, write, delete, and list rights. 已经为容器 https://mystorageaccount.blob.core.windows.net/myfirstcontainer创建与存储访问策略相关联的共享访问签名。A shared access signature that is associated with the stored access policy was created for the container https://mystorageaccount.blob.core.windows.net/myfirstcontainer. 如果已存在 SQL Server 凭据,则步骤几乎一样。The steps are mostly the same if a SQL Server credential already exists. 数据库 Sales 当前在服务器上。The database Sales currently exists on the server. 备份文件为 Sales_stripe1of2_20160601.bakSales_stripe2of2_20160601.bakThe backup files are Sales_stripe1of2_20160601.bak and Sales_stripe2of2_20160601.bak.

  1. 如果已存在 SQL Server 凭据,则从“Azure 存储容器:”下拉列表中选择 https://mystorageaccount.blob.core.windows.net/myfirstcontainer,否则请手动输入容器 https://mystorageaccount.blob.core.windows.net/myfirstcontainer 的名称。 Select https://mystorageaccount.blob.core.windows.net/myfirstcontainer from the Azure storage container: drop-down list if the SQL Server credential already exists, else manually enter the name of the container, https://mystorageaccount.blob.core.windows.net/myfirstcontainer.
  2. 在“共享访问签名:”富文本框中输入共享访问签名。 Enter the shared access signature in the Shared Access Signature: rich-text box.
  3. 单击“确定” 将打开“在 Microsoft Azure 上定位备份文件” 对话框。Click OK and the Locate Backup File in Microsoft Azure dialog box opens.
  4. 展开“容器” 并导航到 https://mystorageaccount.blob.core.windows.net/myfirstcontainerExpand Containers and navigate to https://mystorageaccount.blob.core.windows.net/myfirstcontainer.
  5. 按住 ctrl 并选择文件 Sales_stripe1of2_20160601.bakSales_stripe2of2_20160601.bakHold ctrl and select files Sales_stripe1of2_20160601.bak and Sales_stripe2of2_20160601.bak.
  6. 单击“确定”。 Click OK.
  7. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.
  8. 在“选择页”窗格中单击“选项”。 Click Options in the Select a page pane.
  9. 在“还原选项”部分中,选择“覆盖现有数据库 (WITH REPLACE)”。 Under the Restore options section, check Overwrite the existing database (WITH REPLACE).
  10. 在“结尾日志备份” 部分中,取消选中“还原前执行结尾日志备份” 。Under the Tail-log backup section, uncheck Take tail-log backup before restore.
  11. 在“服务器连接” 部分,选中“关闭目标数据库的现有连接” 。Under the Server connections section, check Close existing connections to destination database.
  12. 单击“确定”。 Click OK.

E2.E2. 共享访问签名不存在A shared access signature does not exist

在本示例中数据库 Sales 当前不在服务器上。In this example the Sales database does not currently exist on the server.

  1. 单击 “添加”将打开 “连接到 Microsoft 订阅”对话框。Click Add and the Connect to a Microsoft Subscription dialog box will open.
  2. 完成 “连接到 Microsoft 订阅”对话框,然后单击 “确定”,返回到 “选择备份文件位置”对话框。Complete the Connect to a Microsoft Subscription dialog box and then click OK to return the Select a Backup File Location dialog box. 有关其他信息,请参阅《Connect to a Microsoft Azure Subscription》(连接到 Microsoft Azure 订阅)。See Connect to a Microsoft Azure Subscription for additional information.
  3. 单击“选择备份文件位置”对话框中单击“确定”将打开“在 Microsoft Azure 上定位备份文件”对话框。 Click OK in the Select a Backup File Location dialog box and the Locate Backup File in Microsoft Azure dialog box opens.
  4. 展开“容器” 并导航到 https://mystorageaccount.blob.core.windows.net/myfirstcontainerExpand Containers and navigate to https://mystorageaccount.blob.core.windows.net/myfirstcontainer.
  5. 选择备份文件,再单击“确定” 。Select the backup file and then click OK.
  6. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.
  7. 单击“确定”。 Click OK.

F.F. 将本地备份还原到 Microsoft Azure 存储 (URL)Restore local backup to Microsoft Azure storage (URL)

将从位于 Sales 的备份中将 https://mystorageaccount.blob.core.windows.net/myfirstcontainer 数据库还原到 Microsoft Azure 存储容器 E:\MSSQL\BAKThe Sales database will be restored to the Microsoft Azure storage container https://mystorageaccount.blob.core.windows.net/myfirstcontainer from a backup located at E:\MSSQL\BAK. 已创建 Azure 容器的 SQL Server 凭据。The SQL Server credential for the Azure container has already been created. 必须已存在目标容器的 SQL Server 凭据,因为不能通过创建 还原 任务创建该凭据。A SQL Server credential for the destination container must already exist as it cannot be created through the Restore task. Sales 数据库当前不在服务器上。The Sales database does not currently exist on the server.

  1. 在“对象资源管理器” 中,连接到一个 SQL Server 数据库引擎实例,然后展开该实例。In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
  2. 右键单击“数据库” ,然后选择“还原数据库...” 。Right-click Databases and select Restore Database....
  3. 在“常规” 页上,在“源” 部分下选择“设备” 。On the General page, select Device under the Source section.
  4. 单击“浏览 (...)”按钮以打开“选择备份设备” 对话框。Click the browse (...) button to open the Select backup devices dialog box.
  5. 从“备份媒体类型:” 下拉列表中选择“文件” 。Select File from the Backup media type: drop-down list.
  6. 单击“添加” 将打开“定位备份文件” 对话框。Click Add and the Locate Backup File dialog box opens.
  7. 导航到 E:\MSSQL\BAK,选择备份文件,再单击“确定”。 Navigate to E:\MSSQL\BAK, select the backup file and then click OK.
  8. 单击“确定”以返回到“常规”页。 Click OK to return to the General page.
  9. 在“选择页”窗格中,单击“文件”。 Click Files in the Select a page pane.
  10. 选中“将所有文件重新定位到文件夹”复选框。 Check the box Relocate all files to folder.
  11. 在“数据文件文件夹:”和“日志文件文件夹:”的文本框中输入容器 https://mystorageaccount.blob.core.windows.net/myfirstcontainerEnter the container, https://mystorageaccount.blob.core.windows.net/myfirstcontainer, in the text boxes for Data file folder: and Log file folder:.
  12. 单击“确定”。 Click OK.

另请参阅See Also

备份事务日志 (SQL Server) Back Up a Transaction Log (SQL Server)
创建完整数据库备份 (SQL Server) Create a Full Database Backup (SQL Server)
将数据库还原到新位置 (SQL Server) Restore a Database to a New Location (SQL Server)
还原事务日志备份 (SQL Server) Restore a Transaction Log Backup (SQL Server)
RESTORE (Transact-SQL) RESTORE (Transact-SQL)
还原数据库(“选项”页) Restore Database (Options Page)
还原数据库(“常规”页)Restore Database (General Page)