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
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
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.
Type: | DateTime |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | AzureSMProfile |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RestorableDropped
Indicates that this cmdlet restores a restorable dropped database.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SourceDatabase
Specifies the name of the database that this cmdlet restores.
Type: | Database |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | 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.
Type: | DateTime |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SourceDatabaseName
Specifies the name of the live database that this cmdlet restores.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | RestorableDroppedDatabase |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | 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.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-TargetDatabaseName
Specifies the name of the new database that the restore operation creates.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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"