Restore-​Azure​Rm​Sql​Database

Restores a SQL database.

Syntax

Restore-AzureRmSqlDatabase
       [-ResourceGroupName] <String>
       [-FromPointInTimeBackup]
       -PointInTime <DateTime>
       -ResourceId <String>
       -ServerName <String>
       -TargetDatabaseName <String>
       [-Edition <DatabaseEdition>]
       [-ServiceObjectiveName <String>]
       [-ElasticPoolName <String>]
       [-InformationAction <ActionPreference>]
       [-InformationVariable <String>]
       [<CommonParameters>]
Restore-AzureRmSqlDatabase
       [-ResourceGroupName] <String>
       [-PointInTime <DateTime>]
       -ResourceId <String>
       -ServerName <String>
       -TargetDatabaseName <String>
       [-Edition <DatabaseEdition>]
       [-ServiceObjectiveName <String>]
       [-ElasticPoolName <String>]
       [-FromDeletedDatabaseBackup]
       -DeletionDate <DateTime>
       [-InformationAction <ActionPreference>]
       [-InformationVariable <String>]
       [<CommonParameters>]
Restore-AzureRmSqlDatabase
       [-ResourceGroupName] <String>
       -ResourceId <String>
       -ServerName <String>
       -TargetDatabaseName <String>
       [-Edition <DatabaseEdition>]
       [-ServiceObjectiveName <String>]
       [-ElasticPoolName <String>]
       [-FromGeoBackup]
       [-InformationAction <ActionPreference>]
       [-InformationVariable <String>]
       [<CommonParameters>]
Restore-AzureRmSqlDatabase
       [-ResourceGroupName] <String>
       -ResourceId <String>
       -ServerName <String>
       -TargetDatabaseName <String>
       [-Edition <DatabaseEdition>]
       [-ServiceObjectiveName <String>]
       [-ElasticPoolName <String>]
       [-FromLongTermRetentionBackup]
       [-InformationAction <ActionPreference>]
       [-InformationVariable <String>]
       [<CommonParameters>]

Description

The Restore-AzureRmSqlDatabase cmdlet restores a SQL database from a geo-redundant backup, a backup of a deleted database, a long term retention backup, or a point in time in a live database. The restored database is created as a new database.

You can create an elastic SQL database by setting the ElasticPoolName parameter to an existing elastic pool.

Examples

Example 1: Restore a database from a point in time

PS C:\>$Database = Get-AzureRmSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzureRmSqlDatabase -FromPointInTimeBackup -PointInTime UTCDateTime -ResourceGroupName $Database.ResourceGroupName -ServerName $Database.ServerName -TargetDatabaseName "RestoredDatabase" -ResourceId $Database.ResourceID -Edition "Standard" -ServiceObjectiveName "S2"

The first command gets the SQL database named Database01, and then stores it in the $Database variable.

The second command restores the database in $Database from the specified point-in-time backup to the database named RestoredDatabase.

Example 2: Restore a database from a point in time to an elastic pool

PS C:\>$Database = Get-AzureRmSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzureRmSqlDatabase -FromPointInTimeBackup -PointInTime UTCDateTime -ResourceGroupName $Database.ResourceGroupName -ServerName $Database.ServerName -TargetDatabaseName "RestoredDatabase" -ResourceId $Database.ResourceID -ElasticPoolName "ElasticPool01"

The first command gets the SQL database named Database01, and then stores it in the $Database variable.

The second command restores the database in $Database from the specified point-in-time backup to the SQL database named RestoredDatabase in the elastic pool named elasticpool01.

Example 3: Restore a deleted database

PS C:\>$DeletedDatabase = Get-AzureRmSqlDeletedDatabaseBackup -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzureRmSqlDatabase -FromDeletedDatabaseBackup -DeletionDate $DeletedDatabase.DeletionDate -ResourceGroupName $DeletedDatabase.ResourceGroupName -ServerName $DeletedDatabase.ServerName -TargetDatabaseName "RestoredDatabase" -ResourceId $DeletedDatabase.ResourceID -Edition "Standard" -ServiceObjectiveName "S2"

The first command gets the backup for the deleted SQL database named database01, and then stores it in the $DeletedDatabase variable.

The second command restores the backup for $DeletedDatabase to the target SQL database named RestoredDatabase.

Example 4: Geo-Restore a database

PS C:\>$GeoBackup = Get-AzureRmSqlDatabaseGeoBackup -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzureRmSqlDatabase -FromGeoBackup -ResourceGroupName "TargetResourceGroup" -ServerName "TargetServer" -TargetDatabaseName "RestoredDatabase" -ResourceId $GeoBackup.ResourceID -Edition "Standard" -RequestedServiceObjectiveName "S2"

The first command gets the geo-redundant backup for the database named Database01, and then stores it in the $GeoBackup variable.

The second command restores the backup in $GeoBackup to the SQL database named RestoredDatabase.

Required Parameters

-DeletionDate

Specifies the deletion date as a DateTime object. To get a DateTime object, use the Get-Date cmdlet.

Type:DateTime
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-FromDeletedDatabaseBackup

Indicates that this cmdlet restores a database from a backup of a deleted SQL database. You can use the Get-AzureRMSqlDeletedDatabaseBackup cmdlet to get the backup of a deleted SQL database.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-FromGeoBackup

Indicates that this cmdlet restores a SQL database from a geo-redundant backup. You can use the Get-AzureRMSqlDatabaseGeoBackup cmdlet to get a geo-redundant backup.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-FromLongTermRetentionBackup

Indicates that this cmdlet restores a SQL database from a long term retention backup.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-FromPointInTimeBackup

Indicates that this cmdlet restores a SQL database from a point-in-time backup.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-PointInTime

Specifies the point in time, as a DateTime object, that you want to restore your SQL database to. To get a DateTime object, use Get-Date cmdlet.Use this parameter together with the FromPointInTimeBackup parameter.

Type:DateTime
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ResourceGroupName

Specifies the name of the resource group to which this cmdlet assigns the SQL database.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceId

Specifies the ID of the resource to restore.

Type:String
Aliases:Id
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ServerName

Specifies the name of the SQL database server.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TargetDatabaseName

Specifies the name of the database to restore to.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-Edition

Specifies the edition of the SQL database. The acceptable values for this parameter are:- None

  • Premium
  • Basic
  • Standard
  • DataWarehouse
  • Free
Type:DatabaseEdition
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ElasticPoolName

Specifies the name of the elastic pool in which to put the SQL database.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.The acceptable values for this parameter are:- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ServiceObjectiveName

Specifies the name of the service objective.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Outputs

Microsoft.Azure.Commands.Sql.Database.Model.AzureSqlDatabaseModel