共用方式為


Start-AzureSqlDatabaseRestore

執行資料庫還原的時間點。

注意

本文件中參考的 Cmdlet 用於管理使用 Azure Service Manager(ASM) API 的舊版 Azure 資源。 建立新的資源時,不建議使用此舊版 PowerShell 模組,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure Service Manager 淘汰

Az PowerShell 模組是使用 PowerShell 管理 Azure Resource Manager (ARM) 資源的建議 PowerShell 模組。

語法

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>]

Description

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 伺服器上名為 Database01 之資料庫的資料庫物件。 命令會 指定 RestorableDropped 參數。 因此,Cmdlet 會取得可還原的卸除資料庫指定的還原點。 命令會將該資料庫物件儲存在 $Database 變數中。

第二個命令會還原$Database所指定的卸除資料庫。 命令會指定新資料庫的名稱。

參數

-PointInTime

指定要還原資料庫的還原點。 當還原作業完成時,資料庫會還原至它在此參數指定的日期和時間的狀態。 根據預設,對於已設定為目前時間的實時資料庫,而對於卸除的資料庫,此 Cmdlet 會使用卸除資料庫的時間。

類型:DateTime
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Profile

指定此 Cmdlet 從中讀取的 Azure 設定檔。 如果您未指定設定檔,此 Cmdlet 會從本機預設配置檔讀取。

類型:AzureSMProfile
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-RestorableDropped

指出此 Cmdlet 會還原可還原的已卸除資料庫。

類型:SwitchParameter
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-SourceDatabase

指定這個 Cmdlet 還原的資料庫名稱。

類型:Database
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-SourceDatabaseDeletionDate

指定刪除資料庫的日期和時間。 當您指定符合實際資料庫刪除時間的時間時,必須包含毫秒。

類型:DateTime
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-SourceDatabaseName

指定此 Cmdlet 所還原之即時資料庫的名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-SourceRestorableDroppedDatabase

指定物件,表示這個 Cmdlet 還原的可還原卸除資料庫。 若要取得 RestoreableDroppedDatabase 物件,請使用 Get-AzureSqlDatabase Cmdlet,並指定 RestoreableDropped 參數。

類型:RestorableDroppedDatabase
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-SourceServerName

指定源資料庫執行所在的伺服器名稱,或源資料庫在刪除之前執行的伺服器名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-TargetDatabaseName

指定還原作業所建立的新資料庫名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-TargetServerName

指定此 Cmdlet 還原資料庫的伺服器名稱。

Azure SQL 資料庫 目前不支援跨伺服器還原。 來源和目標伺服器名稱必須相同。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元: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"