SQL Azure Backup to Windows Azure blobs using Azure management cmdlet (Powershell)

Standard

In my previous post, I discussed how to backup SQL Azure databases to local disks using Azure management cmdlet’s. In this post, we will continue the discussion and see how we could backup the SQLAzure database to Azure blobs. Now before starting, let’s check the cmdlet’s are running fine.

Run the command:

Get-Command –PSSnapin AzureManagementCmdletsSnapIn

1

 

if you have any issues, please read: https://www.cerebrata.com/Docs/AzureManagementCmdlets/readme.pdf

 

Now, let’s see the command that does SQL Azure backup to Azure blobs:

Backup-Database -Name "database1" -DownloadLocation "C:temp" -Server "mydatabaseserver" -UserName "username" -Password "password" -SaveToBlobStorage -BlobContainerName "myblobcontainer" -AccountName "myaccount" -AccountKey "base64 encoded accountkey" -Verbose

Here,

-BlobContainerName is the name of the container in which the files will be stored (on Azure storage)

-Account Name is the name of the Azure storage account which can be found in the Azure management portal

-AccountKey is the key that is required to access the Azure storage account

since we have mentioned –Verbose , we will get description of what’s happening under the hood when the operation is being performed.

On successful completion, you will see something like:

2

 

I had not specified the container, so it created a container in the format: [database name]-backup-[time stamp]

 

Alternatively, if you wish to compress the backup text files and then send it to blobs, a sample command is:

C:PS>Backup-Database -Name "database1" -DownloadLocation "D:temp" -Server "mydatabaseserver" -UserName "username" -Password "password" -SaveToBlobStorage –CompressBlobs -AccountName "myaccount" -AccountKey "base64 encoded accountkey" –Verbose

Notice –CompressBlobs in the command

 

And that’s pretty much it. have fun exploring this powerful powershell CmdLet’s – there are almost 100 of them.

For now, the restore database through the Management CmdLet is not available – But basically the whole point is using Powershell CmdLet’s we will be able to schedule SQL Azure tasks! and that is definitely a good news for an IT pro, right?  

 

related posts:

1. http://parasdoshi.com/2011/06/19/automating-sql-azure-backup-to-on-premise-disks-using-a-sql-azure-management-cmdlet/

2. http://parasdoshi.com/2011/07/05/my-experiments-with-enzo-backup-for-sql-azure-beta-an-one-of-its-kind-tool-for-sql-azure-backups/

Note from Paras: To support this blog and free content here, I partnered with Datacamp for affiliate marketing revenue. I personally use this platform (see my profile here) and highly recommend it. I wouldn't be endorsing them if it wasn't 10/10! Click on the link below to start your journey towards becoming the BEST data professional! datacampParas's datacamp referral link

0 thoughts on “SQL Azure Backup to Windows Azure blobs using Azure management cmdlet (Powershell)

  1. Bharat

    Hello Paras,
    Good information. But if We use the native PS command available of DAC its creating problem. Any suggestion on that.

What do you think? Leave a comment below.