Edit

Share via


Start-AzureSqlDatabaseRecovery

Initiates a restore request for a database.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

BySourceDatabaseName

Start-AzureSqlDatabaseRecovery
    -SourceServerName <String>
    -SourceDatabaseName <String>
    [-TargetServerName <String>]
    [-TargetDatabaseName <String>]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

BySourceDatabaseObject

Start-AzureSqlDatabaseRecovery
    -SourceDatabase <RecoverableDatabase>
    [-TargetServerName <String>]
    [-TargetDatabaseName <String>]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

Description

The Start-AzureSqlDatabaseRecovery cmdlet initiates a restore request for a live or dropped database. This cmdlet supports basic recovery that uses the last known available backup for the database. The recovery operation creates a new database. If you recover a live database on the same server, you must specify a different name for the new database.

To do a point in time restore for a database, use the Start-AzureSqlDatabaseRestore cmdlet instead.

Examples

Example 1: Recover a database specified as an object

PS C:\> $Database = Get-AzureSqlRecoverableDatabase -ServerName "Server01" -DatabaseName "Database17"
PS C:\> $Operation = Start-AzureSqlDatabaseRecovery -SourceDatabase $Database -TargetDatabaseName "DatabaseRestored"

The first command gets a database object by using the Get-AzureSqlRecoverableDatabase cmdlet. The command stores that object in the $Database variable.

The second command recovers the database stored in $Database.

Example 2: Recover a database specified by name

PS C:\> $Operation = Start-AzureSqlDatabaseRecovery -SourceServerName "Server01" -SourceDatabaseName "Database17" -TargetDatabaseName "DatabaseRestored"

This command recovers a database using the database name.

Parameters

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Parameter properties

Type:AzureSMProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SourceDatabase

Specifies the database object that represents the database that this cmdlet recovers.

Parameter properties

Type:RecoverableDatabase
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BySourceDatabaseObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-SourceDatabaseName

Specifies the name of the database that this cmdlet recovers.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BySourceDatabaseName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SourceServerName

Specifies the name of the server on which the source database is live and running, or on which the source database ran before it was deleted.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BySourceDatabaseName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TargetDatabaseName

Specifies the name of the recovered database. If the source database is still live, in order to recover it to the same server, you must specify a name that differs from the source database name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TargetServerName

Specifies the name of the server to which to restore a database. You can restore a database to the same server or to a different server.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

RecoverableDatabase

Outputs

RecoverDatabaseOperation

Notes

  • You must use certificate-based authentication to run this cmdlet. Run the following commands on the computer where you run this 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"