| title | Azure CLI: Restore a backup |
|---|---|
| description | Azure CLI example script to restore a database in Azure SQL Database to an earlier point in time from automatic backups. |
| services | sql-database |
| ms.service | sql-database |
| ms.subservice | backup-restore |
| ms.custom | devx-track-azurecli |
| ms.devlang | azurecli |
| ms.topic | sample |
| author | SQLSourabh |
| ms.author | sourabha |
| ms.reviewer | carlrab |
| ms.date | 12/07/2021 |
This Azure CLI example restores a single database in Azure SQL Database to a specific point in time.
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run az --version to find the version. If you need to install or upgrade, see Install the Azure CLI.
Sign in to Azure using the appropriate subscription. [!INCLUDE quickstarts-free-trial-note]
subscription="<subscriptionId>" # add subscription here
az account set -s $subscription # ...or use 'az login'
For more information, see set active subscription or log in interactively
:::code language="azurecli" source="~/azure_cli_scripts/sql-database/restore-database/restore-database.sh" range="4-39":::
Use the following command to remove the resource group and all resources associated with it.
az group delete --name $resourceGroup
This script uses the following commands. Each command in the table links to command specific documentation.
| Command | Description |
|---|---|
| az sql db restore | Restore database command. |
For more information on the Azure CLI, see Azure CLI documentation.
Additional SQL Database CLI script samples can be found in the Azure SQL Database documentation.