PowerShell script exchange
Post Reply
veremin
Product Manager
Posts: 16778
Liked: 1404 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin » Jul 12, 2019 10:52 am

Is your analysis still in progress or can you already give me an opinion?
The script works in my (and many other environments), so, it's up to you to take the suggested actions to spot the problem. Thanks!

emcclure
Influencer
Posts: 22
Liked: never
Joined: Oct 23, 2018 9:02 pm
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by emcclure » Aug 19, 2019 6:28 pm

So I've been running a script on Veeam Backup 9.4 to backup multiple VM's which has been going great. I looked today at the email and 1 had warning and another had failed. Looking at the warning one it was complaining about snapshots, so I removed them since they weren't needed. The 2nd one has a snapshot from January and I think was recently added to the backup. The script for this vCenter creates a csv file that pulls in the latest VM's in the specified VM folder (As they can change from time to time) and then backs those up. It looks like this has failed on the last 2 and has only been a part of the last 2 backups for it. These are run every 3 days. I'm looking in %PROGRAMDATA%\Veeam\Backup but not seeing any reference to that VM. How do I determine the reason the backup failed for this one? It appears to be running Server 2k8R2. Thanks in advance.

veremin
Product Manager
Posts: 16778
Liked: 1404 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin » Aug 19, 2019 6:45 pm

What does backup console show for this particular VeeamZIP session? Thanks!

emcclure
Influencer
Posts: 22
Liked: never
Joined: Oct 23, 2018 9:02 pm
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by emcclure » Aug 19, 2019 6:53 pm

I don't see anything. Should I? The machines that are successful show successful. The one with the warning showed a warning. I don't see anything for failures at all. Only recent change I made was adding a new host into Veeam that's in the same cluster as the other hosts, however this host doesn't have the failed VM in question, so I don't know what else to say here at the moment.

veremin
Product Manager
Posts: 16778
Liked: 1404 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin » Aug 19, 2019 6:59 pm

Then, it seems that backup activity has not been started for those VMs.

You might want to check the script line by line to catch the issue, especially, the portion where VMs get assigned to variable - whether it contains VMs in question.

Thanks!

emcclure
Influencer
Posts: 22
Liked: never
Joined: Oct 23, 2018 9:02 pm
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by emcclure » Aug 19, 2019 7:10 pm

Hmm so I don't think it's the script. I just looked at the csv file that was created by the first script and sure enough the VM that's failing to backup is there in the csv file along with all the other VM's that backed up without issue (including the one that had the warning for the snapshots).

The script to get the VM's into a csv is as follows (Minus my specific info of course)

Code: Select all

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

$vCName = "myvcenter.domain"
$vcUser = "myuser"
$vcPass = "mypass"
Connect-VIServer -Server $vcName -User $vcUser -Password $vcPass

Get-Datacenter -Name Management | Get-Folder -Name MyFolder | Get-VM | Select Name | Export-csv D:\BackupScript\VMstoBackup.csv
This has been working since the beginning of July.

In the backup script I have this at the beginning:

Code: Select all

$VMNames = Import-csv -Path "D:\BackupScript\VMstoBackup.csv"
Then all the stuff that's defined for my backup and then this:

Code: Select all

 Asnp VeeamPSSnapin

    $mbody = @()
    $VMName = ""

	#$VMs = Find-VBRViEntity -Name * | where {$_.type -eq "VM"}
	
    foreach ($VMName in $VMNames)
    {
	
	$VM = Find-VBRViEntity -Name $VMName.Name
	
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention

    If ($EnableNotification)
    {
    $TaskSessions = $ZIPSession.GetTaskSessions()
    $FailedSessions = $TaskSessions | where {$_.status -eq "EWarning" -or $_.Status -eq "EFailed"}

    if ($FailedSessions -ne $Null)
    {
    $mbody = $mbody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={$FailedSessions.Title}})
    }

    Else
    {
    $mbody = $mbody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={($TaskSessions | sort creationtime -Descending | select -first 1).Title}})
    }

    }
    }
    If ($EnableNotification)
    {
    Send-MailMessage -From $EmailFrom -To $EmailTo -Cc $EmailCC -Subject $EmailSubject -Body ($mbody | Out-String)  -SmtpServer $smtpServer
    }
So I don't understand how 1 VM in a list of 20 or more VM's fails and the rest work just fine. This is all on a scheduled task and the first script runs before the backup script so the list is current each time.

veremin
Product Manager
Posts: 16778
Liked: 1404 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin » Aug 20, 2019 11:51 am

If the backup console does not show a session for VM in question, it means that backup server has not even tried to process this VM.

That's why you need to check the content $VMs variable and see whether it includes problematic VM. If it does, you can try to run VeeamZIP activity only against this VM and see what happens.

Also, you might try to verify whether you can back it up using GUI.

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests