你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Start-AzureSqlDatabaseRestore

执行数据库的时间点还原。

注意

本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧 Azure 资源。 创建新的资源时,不建议使用此旧版 PowerShell 模块,因为 ASM 计划停用。 有关详细信息,请参阅 Azure Service Manager 停用

Az PowerShell 模块是推荐的 PowerShell 模块,用于使用 PowerShell 管理 Azure 资源管理器 (ARM) 资源。

语法

Start-AzureSqlDatabaseRestore
     [-SourceServerName <String>]
     -SourceDatabase <Database>
     [-TargetServerName <String>]
     -TargetDatabaseName <String>
     [-PointInTime <DateTime>]
     [-Profile <AzureSMProfile>]
     [<CommonParameters>]
Start-AzureSqlDatabaseRestore
     [-SourceServerName <String>]
     -SourceRestorableDroppedDatabase <RestorableDroppedDatabase>
     [-TargetServerName <String>]
     -TargetDatabaseName <String>
     [-PointInTime <DateTime>]
     [-Profile <AzureSMProfile>]
     [<CommonParameters>]
Start-AzureSqlDatabaseRestore
     -SourceServerName <String>
     -SourceDatabaseName <String>
     [-TargetServerName <String>]
     -TargetDatabaseName <String>
     [-PointInTime <DateTime>]
     [-Profile <AzureSMProfile>]
     [<CommonParameters>]
Start-AzureSqlDatabaseRestore
     -SourceServerName <String>
     -SourceDatabaseName <String>
     -SourceDatabaseDeletionDate <DateTime>
     [-TargetServerName <String>]
     [-RestorableDropped]
     -TargetDatabaseName <String>
     [-PointInTime <DateTime>]
     [-Profile <AzureSMProfile>]
     [<CommonParameters>]

说明

Start-AzureSqlDatabaseRestore cmdlet 执行基本数据库、标准数据库或高级数据库的时间点还原。 Azure SQL 数据库将基本数据库备份保留 7 天、标准备份 14 天和高级数据库备份 35 天。 还原操作将创建新的数据库。 如果未删除源数据库, 则 SourceDatabaseNameTargetDatabaseName 参数必须具有不同的值。

Azure SQL 数据库目前不支持跨服务器还原。 源和目标服务器名称必须相同。

示例

示例 1:将指定为对象的数据库还原到某个时间点

PS C:\> $Database = Get-AzureSqlDatabase -ServerName "Server01" -DatabaseName "Database17" 
PS C:\> $Operation = Start-AzureSqlDatabaseRestore -SourceDatabase $Database -TargetDatabaseName "DatabaseRestored" -PointInTime "2013-01-01 06:00:00"

第一个命令获取名为 Server01 的服务器中名为 Database17 的数据库的数据库对象,然后将其存储在$Database变量中。

第二个命令将数据库还原到特定的时间点。 该命令指定新数据库的名称。

示例 2:将按名称指定的数据库还原到某个时间点

PS C:\> $Operation = Start-AzureSqlDatabaseRestore -SourceServerName "Server01" -SourceDatabaseName "Database17" -TargetDatabaseName "DatabaseRestored" -PointInTime "2013-01-01 06:00:00"

此命令将名为 Database17 的数据库还原到特定的时间点。 该命令指定新数据库的名称。

示例 3:将指定为对象的已删除数据库还原到某个时间点

PS C:\> $Database = Get-AzureSqlDatabase -RestorableDropped -ServerName "Server01" -DatabaseName "Database01" -DatabaseDeletionDate "2012-11-09T22:59:43.000Z" 
PS C:\> $Operation = Start-AzureSqlDatabaseRestore -SourceRestorableDroppedDatabase $Database -TargetDatabaseName "DroppedDatabaseRestored"

第一个命令获取名为 Server01 的数据库对象。 该命令指定 RestorableDropped 参数。 因此,cmdlet 将获取可还原的删除数据库指定的还原点。 该命令将该数据库对象存储在$Database变量中。

第二个命令还原由$Database指定的已删除数据库。 该命令指定新数据库的名称。

参数

-PointInTime

指定要还原数据库的还原点。 还原操作完成后,数据库将还原到此参数指定的日期和时间的状态。 默认情况下,对于实时数据库,此数据库设置为当前时间,对于已删除的数据库,此 cmdlet 使用删除数据库的时间。

类型:DateTime
Position:Named
默认值:None
必需:False
Accept pipeline input:False
Accept wildcard characters:False

-Profile

指定此 cmdlet 从中读取的 Azure 配置文件。 如果未指定配置文件,此 cmdlet 将从本地默认配置文件中读取。

类型:AzureSMProfile
Position:Named
默认值:None
必需:False
Accept pipeline input:False
Accept wildcard characters:False

-RestorableDropped

指示此 cmdlet 还原可还原的已删除数据库。

类型:SwitchParameter
Position:Named
默认值:None
必需:True
Accept pipeline input:False
Accept wildcard characters:False

-SourceDatabase

指定此 cmdlet 还原的数据库的名称。

类型:Database
Position:Named
默认值:None
必需:True
Accept pipeline input:True
Accept wildcard characters:False

-SourceDatabaseDeletionDate

指定删除数据库的日期和时间。 指定与实际数据库删除时间匹配的时间时,必须包含毫秒数。

类型:DateTime
Position:Named
默认值:None
必需:True
Accept pipeline input:False
Accept wildcard characters:False

-SourceDatabaseName

指定此 cmdlet 还原的实时数据库的名称。

类型:String
Position:Named
默认值:None
必需:True
Accept pipeline input:False
Accept wildcard characters:False

-SourceRestorableDroppedDatabase

指定一个对象,该对象表示此 cmdlet 还原的可还原已删除的数据库。 若要获取 RestorableDroppedDatabase 对象,请使用 Get-AzureSqlDatabase cmdlet,并指定 RestorableDropped 参数。

类型:RestorableDroppedDatabase
Position:Named
默认值:None
必需:True
Accept pipeline input:True
Accept wildcard characters:False

-SourceServerName

指定源数据库在运行和运行的服务器的名称,或源数据库在删除之前运行的服务器的名称。

类型:String
Position:Named
默认值:None
必需:True
Accept pipeline input:False
Accept wildcard characters:False

-TargetDatabaseName

指定还原操作创建的新数据库的名称。

类型:String
Position:Named
默认值:None
必需:True
Accept pipeline input:False
Accept wildcard characters:False

-TargetServerName

指定此 cmdlet 将数据库还原到的服务器的名称。

Azure SQL 数据库目前不支持跨服务器还原。 源和目标服务器名称必须相同。

类型:String
Position:Named
默认值:None
必需:False
Accept pipeline input:False
Accept wildcard characters:False

输入

Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.RestorableDroppedDatabase

Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.Database

输出

Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.RestoreDatabaseOperation

备注

  • 必须使用基于证书的身份验证来运行此 cmdlet。 在运行此 cmdlet 的计算机上运行以下命令:

PS C:\\\> $subId = \<Subscription ID\> PS C:\\\> $thumbprint = \<Certificate Thumbprint\> PS C:\\\> $myCert = Get-Item Cert:\CurrentUser\My\$thumbprint PS C:\\\> Set-AzureSubscription -SubscriptionName "mySubscription" -SubscriptionId $subId -Certificate $myCert PS C:\\\> Select-AzureSubscription -SubscriptionName "mySubscription"