Edit

Share via


Start-AzureSqlDatabaseRestore

Performs a point in time restore of 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

BySourceDatabaseObject

Start-AzureSqlDatabaseRestore
    -SourceDatabase <Database>
    -TargetDatabaseName <String>
    [-SourceServerName <String>]
    [-TargetServerName <String>]
    [-PointInTime <DateTime>]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

BySourceRestorableDroppedDatabaseObject

Start-AzureSqlDatabaseRestore
    -SourceRestorableDroppedDatabase <RestorableDroppedDatabase>
    -TargetDatabaseName <String>
    [-SourceServerName <String>]
    [-TargetServerName <String>]
    [-PointInTime <DateTime>]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

BySourceDatabaseName

Start-AzureSqlDatabaseRestore
    -SourceServerName <String>
    -SourceDatabaseName <String>
    -TargetDatabaseName <String>
    [-TargetServerName <String>]
    [-PointInTime <DateTime>]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

BySourceRestorableDroppedDatabaseName

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

Description

The Start-AzureSqlDatabaseRestore cmdlet performs a point in time restore of a Basic, Standard or Premium database. Azure SQL Database retains Basic database backups 7 days, Standard for 14 days, and Premium for 35 days. The restore operation creates a new database. If the source database is not deleted, the SourceDatabaseName and TargetDatabaseName parameter must have different values.

Azure SQL Database does not currently support cross server restore. The source and target server names must be the same.

Examples

Example 1: Restore a database specified as an object to a point in time

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"

The first command gets a database object for the database named Database17 on the server named Server01, and then stores it in the $Database variable.

The second command restores the database to a specific point in time. The command specifies at name for the new database.

Example 2: Restore a database specified by name to a point in time

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

This command restores the database named Database17 to a specific point in time. The command specifies at name for the new database.

Example 3: Restore a dropped database specified as an object to a point in time

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"

The first command gets a database object for the database named Database01 on the server named Server01. The command specifies the RestorableDropped parameter. Therefore, the cmdlet gets restorable dropped database the specified restore point. The command stores that database object in the $Database variable.

The second command restores the dropped database specified by $Database. The command specifies at name for the new database.

Parameters

-PointInTime

Specifies the restore point to which to restore the database. When the restore operation finishes, the database is restored to the state it was at the date and time that this parameter specifies. By default, for a live database this set to the current time, and for a dropped database, this cmdlet uses the time when the database was dropped.

Parameter properties

Type:DateTime
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

-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

-RestorableDropped

Indicates that this cmdlet restores a restorable dropped database.

Parameter properties

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

Parameter sets

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

-SourceDatabase

Specifies the name of the database that this cmdlet restores.

Parameter properties

Type:Database
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

-SourceDatabaseDeletionDate

Specifies the date and time when the database was deleted. You must include milliseconds when you specify the time to match the actual database deletion time.

Parameter properties

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

Parameter sets

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

-SourceDatabaseName

Specifies the name of the live database that this cmdlet restores.

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
BySourceRestorableDroppedDatabaseName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SourceRestorableDroppedDatabase

Specifies an object that represents the restorable dropped database that this cmdlet restores. To obtain a RestorableDroppedDatabase object, use the Get-AzureSqlDatabase cmdlet, and specify the RestorableDropped parameter.

Parameter properties

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

Parameter sets

BySourceRestorableDroppedDatabaseObject
Position:Named
Mandatory:True
Value from pipeline:True
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

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

-TargetDatabaseName

Specifies the name of the new database that the restore operation creates.

Parameter properties

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

Parameter sets

(All)
Position:Named
Mandatory:True
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 this cmdlet restores the database.

Azure SQL Database does not currently support cross server restore. The source and target server names must be the same.

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

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

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

Outputs

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

Notes

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