还原已启用延伸的数据库 (Stretch Database)Restore Stretch-enabled databases (Stretch Database)

本主题适用于:yesSQL Server(仅从 2016 开始的 Windows)noAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库THIS TOPIC APPLIES TO: yesSQL Server (Windows only starting with 2016)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

必要时,从多种类型的故障、错误和灾难中恢复并还原已备份的数据库。Restore a backed up database when necessary to recover from many types of failures, errors, and disasters.

有关备份的详细信息,请参阅 备份已启用延伸数据库For more info about backup, see Backup Stretch-enabled databases.

提示

备份仅仅是完整的高可用性和业务连续性解决方案的一部分。Backup is only one part of a complete high availability and business continuity solution. 有关高可用性的详细信息,请参阅 高可用性解决方案For more info about high availability, see High Availability Solutions.

还原 SQL Server 数据Restore your SQL Server data

若要从硬件故障或损坏中恢复,请从备份中还原已启用延伸的 SQL Server 数据库。To recover from hardware failure or corruption, restore the Stretch-enabled SQL Server database from a backup. 你也可以继续使用当前使用的 SQL Server 还原方法。You can continue to use the SQL Server restore methods that you currently use. 有关详细信息,请参阅 还原与恢复概述For more info, see Restore and Recovery Overview.

还原 SQL Server 数据库之后,必须运行 sys.sp_rda_reauthorize_db 存储过程,重新建立已启用延伸的 SQL Server 数据库和远程 Azure 数据库之间的连接。After you restore the SQL Server database, you have to run the stored procedure sys.sp_rda_reauthorize_db to re-establish the connection between the Stretch-enabled SQL Server database and the remote Azure database. 有关详细信息,请参阅 还原 SQL Server 数据库和远程 Azure 数据库之间的连接For more info, see Restore the connection between the SQL Server database and the remote Azure database.

还原远程 Azure 数据Restore your remote Azure data

恢复实时 Azure 数据库Recover a live Azure database

在 Azure 快照上的 SQL Server Stretch Database 服务中,所有的实时数据(至少每隔 8 小时)都使用 Azure 存储快照。The SQL Server Stretch Database service on Azure snapshots all live data at least every 8 hours using Azure Storage Snapshots. 这些快照会保留 7 天。These snapshots are maintained for 7 days. 这允许你在过去 7 天到最后一个快照存储的时间段内及时将数据还原到至少 21 个时间点中的其中一个。This allows you to restore the data to one of at least 21 points in time within the past 7 days up to the time when the last snapshot was taken.

若要通过使用 Azure 门户将实时 Azure 数据库还原到较早时间点,请执行以下操作。To restore a live Azure database to an earlier point in time by using the Azure portal, do the following things.

  1. 登录到 Azure 门户Log in to the Azure portal.
  2. 在屏幕左侧选择“浏览”,然后选择“ SQL 数据库”。On the left side of the screen select BROWSE and then select SQL Databases.
  3. 导航到数据库,然后选择它。Navigate to your database and select it.
  4. 在数据库边栏选项卡的顶部,单击“还原”。At the top of the database blade, click Restore.
  5. 指定新的“数据库名称”,选择某个“还原点”,然后单击“创建”。Specify a new Database name, select a Restore Point and then click Create.
  6. 数据库还原过程将开始,可以使用“通知”来监视过程。The database restore process will begin and can be monitored using NOTIFICATIONS.

恢复已删除的 Azure 数据库Recover a deleted Azure database

在被删除之前,Azure 上的 SQL Server Stretch Database 服务将获取数据库快照并保留 7 天。The SQL Server Stretch Database service on Azure takes a database snapshot before a database is dropped and retains it for 7 days. 之后,它不再保留实时数据库的快照。After this occurs, it no longer retains snapshots from the live database. 这使你能够将已删除的数据库还原到被删除的时间点。This lets you restore a deleted database to the point when it was deleted.

若要通过使用 Azure 门户将已删除的数据库还原到被删除的时间点,请执行以下操作。To restore a deleted Azure database to the point when it was deletedby using the Azure portal, do the following things.

  1. 登录到 Azure 门户Log in to the Azure portal.
  2. 在屏幕左侧选择“浏览”,然后选择 “SQL Servers”。On the left side of the screen select BROWSE and then select SQL Servers.
  3. 导航到服务器,然后选择它。Navigate to your server and select it.
  4. 向下滚动到服务器边栏选项卡上的“操作”,单击“已删除的数据库”磁贴。Scroll down to Operations on your server's blade, click the Deleted Databases tile.
  5. 选择要使用的数据库。Select the deleted database you want to restore.
  6. 指定新的数据库名称,然后单击“创建”。Specify a new Database name and click Create.
  7. 数据库还原过程将开始,可以使用“通知”来监视过程。The database restore process will begin and can be monitored using NOTIFICATIONS.

还原 SQL Server 数据库和远程 Azure 数据库之间的连接Restore the connection between the SQL Server database and the remote Azure database

  1. 如果要连接到使用不同的名称或不同区域中的已还原的 Azure 数据库,请运行 sys.sp_rda_deauthorize_db 存储过程,断开与之前 Azure 数据库的连接。If you're going to connect to a restored Azure database with a different name or in a different region, run the stored procedure sys.sp_rda_deauthorize_db to disconnect from the previous Azure database.

  2. 运行 sys.sp_rda_reauthorize_db 存储过程,将已启用延伸的本地数据库重新连接到 Azure 数据库。Run the stored procedure sys.sp_rda_reauthorize_db to reconnect the local Stretch-enabled database to the Azure database.

    • 以 sysname 或 varchar(128) 值的形式提供现有数据库范围凭据。Provide the existing database scoped credential as a sysname or a varchar(128) value. (不要使用 varchar(max)。)可以在视图 sys.database_scoped_credentials 中查找凭据名称。(Don't use varchar(max).) You can look up the credential name in the view sys.database_scoped_credentials.

    • 指定是否复制远程数据的副本并连接到副本(推荐)。Specify whether to make a copy of the remote data and connect to the copy (recommended).

    USE <Stretch-enabled database name>;
    GO
    EXEC sp_rda_reauthorize_db
        @credential = N'<existing_database_scoped_credential_name>',
        @with_copy = 1 ;  
    GO  
    

    另请参阅See Also

    备份已启用延伸数据库Backup Stretch-enabled databases
    对 Stretch Database 进行管理和故障排除 Manage and troubleshoot Stretch Database
    sys.sp_rda_reauthorize_db sys.sp_rda_deauthorize_dbsys.sp_rda_reauthorize_db sys.sp_rda_deauthorize_db
    SQL Server 数据库的备份和还原Back Up and Restore of SQL Server Databases