Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 2.96 KB

File metadata and controls

59 lines (43 loc) · 2.96 KB
title PowerShell: Restore an automatic backup of a database in SQL Database
description Use an Azure PowerShell example script to restore a database in SQL Database to an earlier point in time from automatic backups.
services sql-database
ms.service sql-database
ms.subservice operations
ms.custom
ms.devlang PowerShell
ms.topic sample
author stevestein
ms.author sstein
ms.reviewer
ms.date 03/27/2019

Use PowerShell to restore a database to an earlier point in time

[!INCLUDEappliesto-sqldb]

This PowerShell script example restores a database in SQL Database to a specific point in time.

[!INCLUDE quickstarts-free-trial-note] [!INCLUDE updated-for-az] [!INCLUDE cloud-shell-try-it.md]

If you choose to install and use PowerShell locally, this tutorial requires Az PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount to create a connection with Azure.

Sample script

[!code-powershell-interactivemain]

Clean up deployment

Use the following command to remove the resource group and all resources associated with it.

Remove-AzResourceGroup -ResourceGroupName $resourcegroupname

Script explanation

This script uses the following commands. Each command in the table links to command-specific documentation.

Command Notes
New-AzResourceGroup Creates a resource group in which all resources are stored.
New-AzSqlServer Creates a server that hosts databases and elastic pools.
New-AzSqlDatabase Creates a database in a server.
Get-AzSqlDatabaseGeoBackup Gets a geo-redundant backup of a standalone or pooled database.
Restore-AzSqlDatabase Restores a database.
Remove-AzSqlDatabase Removes a database.
Get-AzSqlDeletedDatabaseBackup Gets a deleted database that you can restore.
Remove-AzResourceGroup Deletes a resource group including all nested resources.

Next steps

For more information on Azure PowerShell, see Azure PowerShell documentation.

Additional SQL Database PowerShell script samples can be found in the Azure SQL Database PowerShell scripts.