Azure Backup with SQL Server Agent and PowerShell

Recently I’ve started using Azure Backup since it offers an acceptable balance of cost, durability and ease of use.

Installing the Azure Backup Agent we can setup up to three scheduled backups of directories. If we have regular SQL Server Agent (or another third-party agent that produces files) then we can utilise the Azure Backup Agent to backup this folder simply. This gives us a relatively cheap off-site solution combined with immediate access to our data for recovery.

Since our backup solution probably uses a SQL Server Agent job to actually do the backups we may want to put our full and differential, and perhaps log, backups into the cloud on completion. We would do our backups to a folder as normal from SQL Server Agent and then use Azure Backup to backup this folder to the cloud.

The Azure Backup Agent actually runs a PowerShell command:

Import-Module MSOnlineBackup; Start-OBBackup -Name “{your key here}”

To get our {your key here} key we need to run another PowerShell command:

Import-Module MSOnlineBackup; Get-OBPolicy

This key can also be found in the Task Scheduler trigger for the online backup.

We can then add this PowerShell command as another step in our SQL Server Agent jobs and then our backup folder will be copied to the cloud once our backup has run.

My Take Away: Excellent easy to setup Cloud Backup solution.

Azure Backup with SQL Server Agent and PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest