Restore-AzSqlDatabase
Restores a SQL database.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
Restore-AzSqlDatabase
[-FromPointInTimeBackup]
-PointInTime <DateTime>
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
[-Edition <String>]
[-ServiceObjectiveName <String>]
[-ElasticPoolName <String>]
[-AsJob]
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromPointInTimeBackup]
-PointInTime <DateTime>
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
-Edition <String>
[-AsJob]
-ComputeGeneration <String>
-VCore <Int32>
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromDeletedDatabaseBackup]
[-PointInTime <DateTime>]
-DeletionDate <DateTime>
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
[-Edition <String>]
[-ServiceObjectiveName <String>]
[-ElasticPoolName <String>]
[-AsJob]
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromDeletedDatabaseBackup]
[-PointInTime <DateTime>]
-DeletionDate <DateTime>
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
-Edition <String>
[-AsJob]
-ComputeGeneration <String>
-VCore <Int32>
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromGeoBackup]
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
[-Edition <String>]
[-ServiceObjectiveName <String>]
[-ElasticPoolName <String>]
[-AsJob]
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromGeoBackup]
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
-Edition <String>
[-AsJob]
-ComputeGeneration <String>
-VCore <Int32>
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromLongTermRetentionBackup]
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
[-Edition <String>]
[-ServiceObjectiveName <String>]
[-ElasticPoolName <String>]
[-AsJob]
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Restore-AzSqlDatabase
[-FromLongTermRetentionBackup]
-ResourceId <String>
-ServerName <String>
-TargetDatabaseName <String>
-Edition <String>
[-AsJob]
-ComputeGeneration <String>
-VCore <Int32>
[-LicenseType <String>]
[-BackupStorageRedundancy <String>]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Restore-AzSqlDatabase 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-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzSqlDatabase -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-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzSqlDatabase -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-AzSqlDeletedDatabaseBackup -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzSqlDatabase -FromDeletedDatabaseBackup -DeletionDate $DeletedDatabase.DeletionDate -ResourceGroupName $DeletedDatabase.ResourceGroupName -ServerName $DeletedDatabase.ServerName -TargetDatabaseName "RestoredDatabase" -ResourceId $DeletedDatabase.ResourceID -Edition "Standard" -ServiceObjectiveName "S2" -PointInTime UTCDateTime
The first command gets the deleted database backup that you want to restore by using Get-AzSqlDeletedDatabaseBackup. The second command starts the restore from the deleted database backup by using the Restore-AzSqlDatabase cmdlet. If the -PointInTime parameter is not specified, the database will be restored to the deletion time.
Example 4: Restore a deleted database into an elastic pool
PS C:\>$DeletedDatabase = Get-AzSqlDeletedDatabaseBackup -ResourceGroupName $resourceGroupName -ServerName $sqlServerName -DatabaseName 'DatabaseToRestore'
PS C:\> Restore-AzSqlDatabase -FromDeletedDatabaseBackup -DeletionDate $DeletedDatabase.DeletionDate -ResourceGroupName $DeletedDatabase.ResourceGroupName -ServerName $DeletedDatabase.ServerName -TargetDatabaseName "RestoredDatabase" -ResourceId $DeletedDatabase.ResourceID -ElasticPoolName "elasticpool01" -PointInTime UTCDateTime
The first command gets the deleted database backup that you want to restore by using Get-AzSqlDeletedDatabaseBackup. The second command starts the restore from the deleted database backup by using Restore-AzSqlDatabase. If the -PointInTime parameter is not specified, the database will be restored to the deletion time.
Example 5: Geo-Restore a database
PS C:\>$GeoBackup = Get-AzSqlDatabaseGeoBackup -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
PS C:\> Restore-AzSqlDatabase -FromGeoBackup -ResourceGroupName "TargetResourceGroup" -ServerName "TargetServer" -TargetDatabaseName "RestoredDatabase" -ResourceId $GeoBackup.ResourceID -Edition "Standard" -ServiceObjectiveName "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.
Parameters
Run cmdlet in the background
| Type: | SwitchParameter |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The Backup storage redundancy used to store backups for the SQL Database. Options are: Local, Zone and Geo.
| Type: | String |
| Accepted values: | Local, Zone, Geo |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The compute generation to assign to the restored database
| Type: | String |
| Aliases: | Family |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
| Type: | SwitchParameter |
| Aliases: | cf |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with azure
| Type: | IAzureContextContainer |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
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 |
| Accept wildcard characters: | False |
Specifies the edition of the SQL database. The acceptable values for this parameter are:
- None
- Basic
- Standard
- Premium
- DataWarehouse
- Free
- Stretch
- GeneralPurpose
- BusinessCritical
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
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 |
| Accept wildcard characters: | False |
Indicates that this cmdlet restores a database from a backup of a deleted SQL database. You can use the Get-AzSqlDeletedDatabaseBackup 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 |
Indicates that this cmdlet restores a SQL database from a geo-redundant backup. You can use the Get-AzSqlDatabaseGeoBackup cmdlet to get a geo-redundant backup.
| Type: | SwitchParameter |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
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 |
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 |
The license type for the Azure Sql database.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
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 |
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 |
| Accept wildcard characters: | False |
Specifies the ID of the resource to restore.
| Type: | String |
| Aliases: | Id |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the name of the SQL database server.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the name of the service objective.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the name of the database to restore to.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The Vcore numbers of the restored Azure Sql Database.
| Type: | Int32 |
| Aliases: | Capacity |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
| Type: | SwitchParameter |
| Aliases: | wi |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |