In this article, I will explain how to restore a backup on Azure Storage to a local sql instance. Before you read this article, you should read the article “How To Backup a SQL Server Database to URL” to create a backup on Azure.
If SAS Token is still valid you can restore a database to local instance from an url with the below script. If SAS token is not valid you should create a SAS token again and create a credential by using this SAS token.
1 2 3 4 5 6 |
USE [master]RESTORE DATABASE [AdventureWorks2014_FromURL] FROM URL = N'https://mynewtestaccount.blob.core.windows.net/mytestcontainer/AdventureWorks2014.bak' WITH FILE = 1, MOVE N'AdventureWorks2014_Data' TO N'C:\SQLServer\AdventureWorks2014_FromURL_Data.mdf', MOVE N'AdventureWorks2014_Log' TO N'C:\SQLServer\AdventureWorks2014_FromURL_Log.ldf', NOUNLOAD, STATS = 1 GO |