none
Mail of succesful files/folders backup RRS feed

  • Question

  • Hi, I have the following code to send me a mail about VM backups, so I get an overview every day if my VM backups were successful or not.

    $azureAccName = "xxxxxxxxxxxxxxx"
    $azurePass = "xxxxxxxxxxxxxxxxx" | ConvertTo-SecureString -AsPlainText -Force
    $credentials = New-Object System.Management.Automation.PSCredential($azureAccName,$azurePass)
    Login-AzureRmAccount -Credential $credentials
    $subs = Get-AzureRmSubscription
    $DAILYBACKUPSTATS= @()
    for($i = 0; $i -le $subs.length; $i++){
        if($subs[$i]){
            Select-AzureRmSubscription -SubscriptionId $subs[$i].SubscriptionId -TenantId $subs[$i].TenantId
            $rsv = Get-AzureRmRecoveryServicesVault
            echo $rsv
            for($j = 0; $j -le $rsv.length; $j++){
                if($rsv[$j]){
                    Get-AzureRmRecoveryServicesVault -Name $rsv[$j].Name | Set-AzureRmRecoveryServicesVaultContext
                    $joblist = Get-AzureRmRecoveryServicesBackupJob -From (Get-Date).AddDays(-1).ToUniversalTime() -To (Get-Date).ToUniversalTime()
                    if($joblist){
                    foreach($job in $joblist){
                        $stats = New-Object System.Object
                        $stats | Add-Member -Type NoteProperty -Name Klant -Value $rsv[$j].Name
                        $stats | Add-Member -Type NoteProperty -Name VMName -Value $job.WorkloadName
                        $stats | Add-Member -Type NoteProperty -Name Status -Value $job.Status
                        $stats | Add-Member -Type NoteProperty -Name Starttijd -Value $job.StartTime
                        $stats | Add-Member -Type NoteProperty -Name Eindtijd -Value $job.EndTime
                        $stats | Add-Member -Type NoteProperty -Name Duration -Value $job.Duration
                        $DAILYBACKUPSTATS += $stats

                         }
                    }
                }
            }
        }
    }
    $DAILYBACKUPSTATS | Out-GridView
    $DAILYBACKUPSTATS | Export-Csv 'C:\Script-shared-platform\backup-sharedplatform.csv'

    $secpasswd = ConvertTo-SecureString "xxxxxxxxxxxxxxxx"-AsPlainText -Force
    $myCreds = New-Object System.Management.Automation.PSCredential ("ssssss@dddddddddd.be", $secpasswd)
    Send-MailMessage -To "ssssss@sssss.ddddd"  -Attachments "C:\Script\bK-sharedplatform.csv" -SmtpServer "smtp.office365.com" -Credential $myCreds -UseSsl "Backup Notification Shared Azure" -Port "587" -Body "Backup Azure VM's Shared Platform" -From "dsmlkdsdsmlk@dsmkjdsml.beekjl" -BodyAsHtml

    But how do I do the same for Files/Folders backup?

    Maybe helpful or useless: the backup is done on a non azure server, but backupped with MARS. 


    Friday, November 29, 2019 9:25 AM

All replies

  • You can use Activity log based alerting for backups. Please refer to the following article for more details – https://docs.microsoft.com/en-us/azure/backup/backup-azure-monitor-vms#using-activity-logs-to-get-notifications-for-successful-backups
    Monday, December 2, 2019 2:09 PM
    Moderator
  • Have you had a chance to see the previous? If the suggestions were helpful, click “Mark as Answer” and Up-Vote. Feel free to reach out to us if you've additional questions in this regard.
    Wednesday, December 4, 2019 1:00 PM
    Moderator
  • But then I would have to enable/configure this for all my clients, I would like to do this just from a script like I had before?

    plus, no that is not a solution my boss wants as this will not send a mail on a succesfull backup.

    PLus, even if it did it would send a lot of mails, instead of just one with a nice overview of all backups.

    Monday, December 9, 2019 2:08 PM
  • Can you share a overview screenshot of the VM backups showing details of successful or failure backups. I can discuss this with the concerned team and get back to you with an update.
    Tuesday, December 10, 2019 6:21 AM
    Moderator
  • We receive an excel file like below of all backups of all clients, using the code from above:

    

    

    But this is for VM backup, it is not for File backup.

    I want the same for File backup.

    Tuesday, December 10, 2019 8:20 AM
  • Hi Nick,

    I see that you are using AzueRM Recovery services module for fetching jobs. This is the right way but PS doesn't support fetching jobs from file-folder backups as of now. It is only built for fetching information for backups of Azure resources such as VM backups.

    What are the alternatives:

    1) We can fetch the file folder backup jobs from REST API. You can use PS to script it.
    2) Please refer to this article about using Log analytics to get the same data. The earlier article which mentions using activity logs doesn't suit your requirements. But Log analytics will definitely suit all your requirements.

    We would recommend option 2. Please read the article and let us know your response.

    Regards

    Wednesday, December 11, 2019 11:29 AM
    Moderator