--- 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]( /cli/azure/install-azure-cli). ## Sample script ### Sign in to Azure Sign in to Azure using the appropriate subscription. [!INCLUDE [quickstarts-free-trial-note](../../../../includes/quickstarts-free-trial-note.md)] ```azurecli-interactive subscription="" # add subscription here az account set -s $subscription # ...or use 'az login' ``` For more information, see [set active subscription](/cli/azure/account#az_account_set) or [log in interactively](/cli/azure/reference-index#az_login) ### 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. ```azurecli 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](/cli/azure/sql/db#az_sql_db_restore) | Restore database command. | ## Next steps For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure). Additional SQL Database CLI script samples can be found in the [Azure SQL Database documentation](../../../azure-sql/database/az-cli-script-samples-content-guide.md).