Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Restoring database from Azure Blob storage


This recipe walks you through how to restore a database to a local instance from a backup stored in Azure.

Getting ready

For this recipe, you need to have already performed a backup to Azure Blob storage. If you haven't already done so, you can refer to the recipe Backing up database to Azure Blob storage to prepare your environment.

How to do it...

These are the steps to change the recovery model:

  1. Open PowerShell ISE as administrator.

  2. Import the SQLPS module as follows:

    #import SQL Server module
    Import-Module SQLPS -DisableNameChecking
  3. Add the following script and run:

    $AzureStorageAccount = "replaceThisWithAzureStorageAccount"
    $credentialName = "AzureCredential"
    
    #replace values specific to your Azure account
    $blobContainer = "replaceWithYourContainerName"
    $backupUrlContainer = "https://$AzureStorageAccount.blob.core.windows.net/$blobContainer/"
    	
    $backupfile = "replacethiswithyourazurefilename.bak"
    $backupfileURL = $backupUrlContainer + $backupfile
    
    ...