Skip to content

Latest commit

 

History

History
59 lines (40 loc) · 2.14 KB

File metadata and controls

59 lines (40 loc) · 2.14 KB
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

Use CLI to restore a single database in Azure SQL Database to an earlier point in time

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.

Sample script

Sign in to Azure

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

Run the script

:::code language="azurecli" source="~/azure_cli_scripts/sql-database/restore-database/restore-database.sh" range="4-39":::

Clean up deployment

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

az group delete --name $resourceGroup

Sample reference

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.

Next steps

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.