Detecting incomplete backups

PowerShell script exchange

Detecting incomplete backups

Veeam Logoby swizzle » Mon Dec 26, 2011 9:24 pm

Does anybody have a script that checks if a Veeam snapshot exists on a vm before attempting to backup?

Bad things happen if Veeam attempts to backup a vm that is already being backed up (by another instance) or is in an incomplete state due to a previous failed backup.

My idea is to test the state of each vm in the script and either wait for the snapshot(s) to be deleted before continuing, or skip the vm (potentially returning to it at the end of the backup run).
swizzle
Novice
 
Posts: 8
Liked: never
Joined: Fri Jun 11, 2010 9:28 pm
Location: New Zealand
Full Name: Peter Mott

Re: Detecting incomplete backups

Veeam Logoby Gostev » Mon Dec 26, 2011 10:00 pm

swizzle wrote:Bad things happen if Veeam attempts to backup a vm that is already being backed up (by another instance) or is in an incomplete state due to a previous failed backup.

v6 has no issues with either scenario, so bad things don't happen.
Gostev
Veeam Software
 
Posts: 21390
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Detecting incomplete backups

Veeam Logoby jkcouch » Wed Dec 28, 2011 4:31 am

What version of Veeam are you using & how are you building your jobs? By that I mean are you using folders in vcenter, datastores or individual virtual machines?

In my environment, I use v6 and only backup by VM object. This way I can easily determine what job my vm is in on the same server. I use the following script as a check to ensure that I don’t backup an object twice by mistake. I run this daily after another script polls vCenter for new VMs. You can schedule it and send the output to email if there are any duplicate vm objects to report. I hope you can find it useful.


Code: Select all
Function Get-Duplicate {
    param($array, [switch]$count)
    begin {
        $hash = @{}
    }
    process {
        $array | %{ $hash[$_] = $hash[$_] + 1 }
        if($count) {
            $hash.GetEnumerator() | ?{$_.value -gt 1} | %{
                New-Object PSObject -Property @{
                    Value = $_.key
                    Count = $_.value
                }
            }
        }
        else {
            $hash.GetEnumerator() | ?{$_.value -gt 1} | %{$_.key}
        }
    }
}

$Jobs = Get-VBRJob

# get all objects in Jobs
$JobObjectReport = @()
foreach ($job in $jobs){
   $Objects = Get-VBRJobobject -job $job
      Foreach ($Object in $Objects){
   $JobObjects = "" | select Name, JobName, ApproxSize
   $JobObjects.Name = $Object.Name
   $JobObjects.JobName = $job.Name
   $JobObjects.ApproxSize = ($Object.ApproxSizeString).split(' ')[0]
   $JobObjectReport += $JobObjects
   }
}


$VMObjects = New-Object System.Collections.ArrayList
foreach ($VMObject in $JobObjectReport){
   [Void] $VMObjects.Add($VMobject.Name)
   }

$DuplicateReport = @()
foreach ($Item in $Duplicates){
   foreach ($VMObject in $JobObjectReport){
      if ($Item -eq $VMobject.Name){
         $DuplicateReport +=$VMobject
         }
      }
   }
   
$DuplicateReport

jkcouch
Enthusiast
 
Posts: 30
Liked: never
Joined: Sun Jun 26, 2011 7:02 pm
Full Name: Jeff Couch


Return to PowerShell



Who is online

Users browsing this forum: Bing [Bot] and 3 guests