none
Azure VM Backup report RRS feed

  • Question

  • Hi all -

    We have around 350 Azure IaaS VM (windows + Linux) running on Azure. All the VM has been configured with azure native backup and spread across the 10 subscription.

    We are looking for automated daily Azure VM backup status report for all the VMs in CSV/Excel format. Is it possible to send the daily email for all the VM backup status in xls format.

    We already have the azure backup failure alert configured.

    Thanks,


    suhag

    Friday, November 15, 2019 7:28 PM

Answers

  • Hi Suhag,

    You can use Azure Log Analytics query to get list of backup jobs.

    This will give you an option to list all virtual machine backup jobs status (failed and success).

    You can also configure dashboard and share it with the team

    You can write query and configure it for alert , whenever the query executed you will get alerts.  Here is the sample query I am adding.

    AzureDiagnostics

    | whereTimeGenerated > ago(1d)

    | whereCategory == "AzureBackupReport"

    | whereOperationName == "Job" andJobOperation_s == "Backup" andBackupManagementType_s == "IaaSVM"

    //| where todouble(DataTransferredInMB_s)>1

    //| extend Report_Running_Time_UTC= TimeGenerated

    | extendBackup_Job_Start_Time = JobStartDateTime_s

    // If we want time in AM or PM format and want to make more readable then uncomment below line by removing //

    | where(Backup_Job_Start_Time contains "AM" orBackup_Job_Start_Time contains "PM")

    //| extend DataTransferedGB = todouble(DataTransferredInMB_s)/1024

    | extendJobDurationHour = todouble(JobDurationInSecs_s)/3600

    //| where JobDurationHour > 3

    | extendVault_Name = split(ResourceId, '/')[-1]

    | extendServer_Name = split(BackupItemUniqueId_s, ';')[-1]

    | extendRSV_Location = split(VaultUniqueId_s,';')[0]

    | projectBackup_Job_Start_Time,Vault_Name, Server_Name, RSV_Location, JobStatus_s, JobFailureCode_s , JobDurationHour, ResourceGroup, SubscriptionId , Level

    Output Format.

    Backup_Job_Start_Time

    Vault_Name

    Server_Name

    RSV_Location

    JobStatus_s

    JobFailureCode_s

    JobDurationHour

    ResourceGroup

    SubscriptionId

    Level

     

    If not you can use below powershell script to get list of backup items with last backup status.

    $azure_recovery_services_vault_list= Get-AzureRmRecoveryServicesVault

     

    $backup_details= $null

    $backup_details= @()

     

    foreach($azure_recovery_services_vault_list_iterator in $azure_recovery_services_vault_list){

     

        Set-AzureRmRecoveryServicesVaultContext -Vault $azure_recovery_services_vault_list_iterator

     

        $container_list = Get-AzureRmRecoveryServicesBackupContainer -ContainerType  AzureSQL

     

        foreach($container_list_iterator in $container_list){

     

            

            $backup_item = Get-AzureRmRecoveryServicesBackupItem -Container $container_list_iterator -WorkloadType AzureSQL

            $backup_item_array = ($backup_item.ContainerName).split(';')

            $backup_item_resource_name = $backup_item_array[1]

            $backup_item_vm_name = $backup_item_array[2]

            $backup_item_last_backup_status = $backup_item.LastBackupStatus

            $backup_item_latest_recovery_point = $backup_item.LatestRecoveryPoint

     

            $backup_details_temp = New-Object psobject

     

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "ResourceGroupName" -Value $backup_item_resource_name

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "VMName" -Value $backup_item_vm_name

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "VaultName" -Value $azure_recovery_services_vault_list_iterator.Name

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "BackupStatus" -Value $backup_item_last_backup_status

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "LatestRecoveryPoint" -Value $backup_item_latest_recovery_point

     

            $backup_details = $backup_details + $backup_details_temp

     

        }

     

    }

     

    # Exporting the data to csv

    $backup_details| Export-Csv "vm_backup_status.csv" -NoTypeInformation -NoClobber

    • Marked as answer by Suhag Desai Monday, November 18, 2019 12:29 PM
    Monday, November 18, 2019 11:04 AM

All replies

  • Hi Suhag,

    You can use Azure Log Analytics query to get list of backup jobs.

    This will give you an option to list all virtual machine backup jobs status (failed and success).

    You can also configure dashboard and share it with the team

    You can write query and configure it for alert , whenever the query executed you will get alerts.  Here is the sample query I am adding.

    AzureDiagnostics

    | whereTimeGenerated > ago(1d)

    | whereCategory == "AzureBackupReport"

    | whereOperationName == "Job" andJobOperation_s == "Backup" andBackupManagementType_s == "IaaSVM"

    //| where todouble(DataTransferredInMB_s)>1

    //| extend Report_Running_Time_UTC= TimeGenerated

    | extendBackup_Job_Start_Time = JobStartDateTime_s

    // If we want time in AM or PM format and want to make more readable then uncomment below line by removing //

    | where(Backup_Job_Start_Time contains "AM" orBackup_Job_Start_Time contains "PM")

    //| extend DataTransferedGB = todouble(DataTransferredInMB_s)/1024

    | extendJobDurationHour = todouble(JobDurationInSecs_s)/3600

    //| where JobDurationHour > 3

    | extendVault_Name = split(ResourceId, '/')[-1]

    | extendServer_Name = split(BackupItemUniqueId_s, ';')[-1]

    | extendRSV_Location = split(VaultUniqueId_s,';')[0]

    | projectBackup_Job_Start_Time,Vault_Name, Server_Name, RSV_Location, JobStatus_s, JobFailureCode_s , JobDurationHour, ResourceGroup, SubscriptionId , Level

    Output Format.

    Backup_Job_Start_Time

    Vault_Name

    Server_Name

    RSV_Location

    JobStatus_s

    JobFailureCode_s

    JobDurationHour

    ResourceGroup

    SubscriptionId

    Level

     

    If not you can use below powershell script to get list of backup items with last backup status.

    $azure_recovery_services_vault_list= Get-AzureRmRecoveryServicesVault

     

    $backup_details= $null

    $backup_details= @()

     

    foreach($azure_recovery_services_vault_list_iterator in $azure_recovery_services_vault_list){

     

        Set-AzureRmRecoveryServicesVaultContext -Vault $azure_recovery_services_vault_list_iterator

     

        $container_list = Get-AzureRmRecoveryServicesBackupContainer -ContainerType  AzureSQL

     

        foreach($container_list_iterator in $container_list){

     

            

            $backup_item = Get-AzureRmRecoveryServicesBackupItem -Container $container_list_iterator -WorkloadType AzureSQL

            $backup_item_array = ($backup_item.ContainerName).split(';')

            $backup_item_resource_name = $backup_item_array[1]

            $backup_item_vm_name = $backup_item_array[2]

            $backup_item_last_backup_status = $backup_item.LastBackupStatus

            $backup_item_latest_recovery_point = $backup_item.LatestRecoveryPoint

     

            $backup_details_temp = New-Object psobject

     

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "ResourceGroupName" -Value $backup_item_resource_name

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "VMName" -Value $backup_item_vm_name

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "VaultName" -Value $azure_recovery_services_vault_list_iterator.Name

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "BackupStatus" -Value $backup_item_last_backup_status

            $backup_details_temp | Add-Member -MemberType NoteProperty -Name "LatestRecoveryPoint" -Value $backup_item_latest_recovery_point

     

            $backup_details = $backup_details + $backup_details_temp

     

        }

     

    }

     

    # Exporting the data to csv

    $backup_details| Export-Csv "vm_backup_status.csv" -NoTypeInformation -NoClobber

    • Marked as answer by Suhag Desai Monday, November 18, 2019 12:29 PM
    Monday, November 18, 2019 11:04 AM
  • Just Modify ContainerType and WorkloadType to AzureVM in Power Shell script 
    Monday, November 18, 2019 11:08 AM