Start-VBRZip in Veeam Backup Free Edition

PowerShell script exchange

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Mon Mar 20, 2017 4:15 pm

So my question is, if I have '-AutoDelete 'In2Weeks’' - who is responsible of the erasing?

Backup server.

Also, If I doesn't want to autodelete the backup after the backup is done, How can I remove this 'auto delete' parameter from the backup file? ( after the file is already created with the -autodelete option )

Copy backup to a different location.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby MiguelLagos » Fri Apr 07, 2017 12:34 pm

I started to use Mr. Eremin script with Veeam Backup Free Edition 9.5 update 1 on Windows 2016 Server with Hyper-v.

When I run it I obtain this error message: Start-VBRZip: Cannot validate argument on parameter 'Entity'. The argument is null. Provide
a valid value for the argument, and then try running the command again.

I debugged the script running the commands from the PS prompt:

PS c:\Get-VBRServer -name "myserver.mydomain.com" (It's OK)

PS c:\$Server = Get-VBRServer -name "myserver.mydomain.com" (It's OK)

PS c:\$VMName = "MyVM" (It's OK)

PS c:\Find-VBRHvEntity -Name $VMName -Server $Server (It returns nothing)

No error message, just nothing.
Any idea?
MiguelLagos
Lurker
 
Posts: 2
Liked: never
Joined: Fri Apr 07, 2017 12:37 am
Full Name: Miguel Angel Lagos

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby MagnaVis » Mon Apr 10, 2017 12:48 am

MiguelLagos wrote:PS c:\Find-VBRHvEntity -Name $VMName -Server $Server (It returns nothing)

Have you done
Code: Select all
Write-Host $Server

to make sure the variable holds the correct value? The only reason I could see your command coming back empty is if the VMName or Server aren't set correctly. Is there a larger reference for the Find-VBRHvEntity command? Is there a way to run it without variables to see what it comes back with?

I can check a few things on my 2016 environment at work tomorrow when I get in if you haven't fix it by then.
MagnaVis
Influencer
 
Posts: 10
Liked: 2 times
Joined: Fri Nov 06, 2015 5:05 pm
Full Name: Ricky

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Mon Apr 10, 2017 11:00 am

Can you try to input one of the following one-liners and see whether VM with the said name gets returned among other HV entities:

Code: Select all
Find-VBRHvEntity -Server $Server


Code: Select all
Find-VBRHvEntity -Server (Get-VBRServer -name "name of your server")


Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby BpMaster » Thu Apr 13, 2017 7:01 am

Hey Guys,

can everyone help me with this error message? I extended the Powershell script to automatically integrate virtual machines, but it doesn't work. :(

Code: Select all
# Names of VMs to backup separated by comma (Mandatory). For instance, $VMNames = “VM1”,”VM2”
$Ausgabe = ''
$VMs = (Get-VM)
foreach ($VM in $VMs) {
    $Ausgabe = $Ausgabe + '"' + $VM.Name + '",'
}
$VMNames = $Ausgabe.trimEnd(',')


Unfortunately in german :/

Code: Select all
Find-VBRHvEntity : Das Argument für den Parameter "Server" kann nicht überprüft werden. Das Argument ist NULL. Geben Sie einen gültigen Wert für das Argument an, und führen Sie den Befehl
erneut aus.
In D:\Tools\Veeam_Backup.ps1:82 Zeichen:48
+   $VM = Find-VBRHvEntity -Name $VMName -Server $Server
+                                                ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Find-VBRHvEntity], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.FindVBRHvEntity
 
Start-VBRZip : Der Parameter "Entity" kann nicht gebunden werden. Der Wert "Microsoft.HyperV.PowerShell.VirtualMachine" vom Typ "Microsoft.HyperV.PowerShell.VirtualMachine" kann nicht in
den Typ "Veeam.Backup.Common.IItem" konvertiert werden.
In D:\Tools\Veeam_Backup.ps1:92 Zeichen:40
+     $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $Comp ...
+                                        ~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-VBRZip], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Cmdlets.StartVBRZip
 
Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
In D:\Tools\Veeam_Backup.ps1:97 Zeichen:5
+     $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().updatedrecords
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Ausnahme beim Aufrufen von "Send" mit 1 Argument(en):  "Fehler beim Senden von Mail."
In D:\Tools\Veeam_Backup.ps1:119 Zeichen:1
+ $SMTP.Send($Message)
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SmtpException


Any idea?
BpMaster
Lurker
 
Posts: 1
Liked: never
Joined: Thu Apr 13, 2017 6:43 am
Full Name: Felix Mayer

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Thu Apr 13, 2017 1:12 pm

It means that $Server variable contains Null value, thus the script fails. Check how this variable gets assigned - the proper name is used, this server exists indeed and can be seen in backup console, etc. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby Mike Resseler » Fri Apr 14, 2017 5:34 am

There is another thread that looks like it had the same problem: powershell-f26/nothing-happens-when-i-execute-the-veeam-powershell-script-t42237-15.html

v.Eremin has posted a script over there to check whether the Variables get populated. (in the other thread, the name of the VM was wrong)

Code: Select all
Asnp VeeamPSSnapin
$VMName = "nameVMasSeenInHyperVManager"
$HostName = "HyperVHostName"
$Server = Get-VBRServer -name $HostName
$Server
$VM = Find-VBRHvEntity -Name $VMName -Server $Server
$VM


Can you run this to check if the $Server and $VM variables get populated and post the results?
Mike Resseler
Veeam Software
 
Posts: 3165
Liked: 362 times
Joined: Fri Feb 08, 2013 3:08 pm
Location: Belgium, the land of the fries, the beer, the chocolate and the diamonds...
Full Name: Mike Resseler

[MERGED] Powershell script failing for scripted backups?

Veeam Logoby Hawkest1977 » Wed May 03, 2017 3:52 pm

Hello,

I am getting this same error. However; I am using the right one for VMware.
I am not sure what the issue is.

Code: Select all
Asnp VeeamPSSnapin

$Server = Get-VBRServer -name $HostName
$MesssagyBody = @()

foreach ($VMName in $VMNames)
{
  $VM = Find-VBRViEntity -Name $VMName -Server $Server
 
  If ($EnableEncryption)
  {
    $EncryptionKey = Add-VBREncryptionKey -Password (cat $EncryptionKey | ConvertTo-SecureString)
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -EncryptionKey $EncryptionKey
  }
 
  Else
  {
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention
  }
 
  If ($EnableNotification)
  {
    $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().updatedrecords
    $FailedSessions =  $TaskSessions | where {$_.status -eq "EWarning" -or $_.Status -eq "EFailed"}
 
  if ($FailedSessions -ne $Null)
  {
    $MesssagyBody = $MesssagyBody + ($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
  {
    $MesssagyBody = $MesssagyBody + ($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)
{
$Message = New-Object System.Net.Mail.MailMessage $EmailFrom, $EmailTo
$Message.Subject = $EmailSubject
$Message.IsBodyHTML = $True
$message.Body = $MesssagyBody | ConvertTo-Html -head $style | Out-String
$SMTP = New-Object Net.Mail.SmtpClient($SMTPServer)
$SMTP.Send($Message)
}

The error I get is as follows,

Code: Select all
Find-VBRViEntity : Cannot validate argument on parameter 'Server'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At C:\Users\administrator.RTTECHDEV\Desktop\Backup.ps1:45 char:48
+   $VM = Find-VBRViEntity -Name $VMName -Server $Server
+                                                ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Find-VBRViEntity], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.FindVBRViEntity
 
Start-VBRZip : Cannot validate argument on parameter 'Entity'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At C:\Users\administrator.RTTECHDEV\Desktop\Backup.ps1:55 char:40
+     $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $Comp ...
+                                        ~~~
    + CategoryInfo          : InvalidData: (:) [Start-VBRZip], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVBRZip
Hawkest1977
Lurker
 
Posts: 2
Liked: never
Joined: Wed May 03, 2017 3:46 pm
Full Name: Tasha Hawkes

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Thu May 04, 2017 12:38 pm

This means that $Server variable contains $Null value. Are you positive that you've input a correct server name and that the server is added to a backup console under the very same name?

Run this code and see whether it returns anything:

Code: Select all
Asnp VeeamPSSnapin
$Server = Get-VBRServer -name "Name of your server"
$Server

Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby Hawkest1977 » Thu May 04, 2017 1:08 pm

Yes, I got it working but now it will only back up three of the five VM's in the list. I am trying to get this to run as a scheduled task, which does not seem to work well with powershell scripts. I am half way there. However; I am not sure why it will only back up a few of the listed VM's. If I run it in PowerShellISE, it works perfectly. Just not with Powershell itself.
Hawkest1977
Lurker
 
Posts: 2
Liked: never
Joined: Wed May 03, 2017 3:46 pm
Full Name: Tasha Hawkes

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Thu May 04, 2017 1:16 pm

Hmm, strange. Will a script return all five VMs, if you run the following line:

Code: Select all
foreach ($VMName in $VMNames)
{
  $VM = Find-VBRViEntity -Name $VMName -Server $Server
  $VM
}

Also, what PS version are you using? And aren't you backing up VMs to CIFS share by any chance?

Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Mon May 15, 2017 8:09 pm

Hey, everyone, Update 2 with -NetworkCredentials parameter for Start-VBRZip cmdlet has just become available, which means previous tricks with tweaking permissions on target share are no longer needed. Enjoy.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby nzorn » Fri May 19, 2017 7:02 pm

Sweet! Do you think the blog/script listed on the the first post (https://www.veeam.com/blog/veeam-backup ... shell.html) will be updated to include this?
nzorn
Influencer
 
Posts: 12
Liked: never
Joined: Thu Nov 13, 2014 2:57 pm

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby v.Eremin » Wed May 31, 2017 9:21 am

I haven't thought about updating my original blog post, as changes needed seem quite trivial (may be just to me).

Basically, to make script work with network shares you have to specify share path and credentials to connect to it, using -Folder <String> and -NetworkCredentials <PSCredential> parameters, accordingly.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRZip in Veeam Backup Free Edition

Veeam Logoby shlomia » Thu Jun 08, 2017 9:14 am

Hi People,
How is it possible to specify backup proxy in the jobs?
this is the script I'm running:
D:\VeeamScripts\VeeamZip.ps1 –VM ‘VirtualMachineName’ –Destination ‘\\storage\backup\VeeamBackup’ –AutoDelete 'In2Weeks’ –Compression 5 –DisableQuiesce $false

I added windows server as backup proxy but I have no clue how to specify the job to use it.

Thank you
shlomia
Novice
 
Posts: 9
Liked: never
Joined: Mon Mar 20, 2017 3:40 pm
Full Name: Shlomi

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests