PowerShell script exchange
Post Reply
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Surebackup verification - design.

Post by JLundgren »

Hello,

I have got a request from a customer.
They need to verify via Surebackup that ALL virtual machines in their VMware vSphere environment should be tested at least once per year.
In this case it means way over 300 vm.

In what way would you configure that ?
Is this even viable ?

Regards,
JLundgren
Regards,

JLundgren
Mike Resseler
Product Manager
Posts: 8191
Liked: 1322 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Surebackup verification - design.

Post by Mike Resseler »

Hey Johnny,

That would require quite some manual work, or (my suggestion) it would be scripting. What I would do here is to create some dummy surebackup job, and then use PowerShell to populate the job through an exported CSV or something like that. Luca has once blogged something around a script that is pretty close to what you want: https://www.virtualtothecore.com/en/can ... urebackup/
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

Hello,

I have tried to test the updated script on Github in my test-Environment, a Windows Server 2016 and VBR 9.5.
I have created a vLab with the corresponding name as suggested in the article.

https://github.com/dellock6/veeam-power ... backup.ps1

However, I get the following errors (the first error is repeated several times but I have excluded it).
In short, the error is about a key or argument that cannot be null.

Any ideas ?

Code: Select all

C:\Backup>powershell c:\backup\dynamicvm.ps1

Exception calling "set_Item" with "2" argument(s): "Key cannot be null.
Parameter name: key"
At C:\backup\dynamicvm.ps1:88 char:9
+         $fHashtable.Set_Item($fHashtableOrdered[$i].Name, 1)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

Find-VBRViEntity : Cannot validate argument on parameter 'Name'. The argument is null, empty, or an element of the argu
ment collection contains a null value. Supply a collection that does not contain any null values and then try the comma
nd again.
At C:\backup\dynamicvm.ps1:112 char:101
+ ... p -Name $AppGroupName -VmFromBackup (Find-VBRViEntity -Name $TestVMs)
+                                                                 ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Find-VBRViEntity], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.FindVBRViEntity

Add-VSBJob : Cannot validate argument on parameter 'AppGroup'. The argument is null. Provide a valid value for the argu
ment, and then try running the command again.
At C:\backup\dynamicvm.ps1:113 char:77
+ ...  -Name $SbJobName -VirtualLab $VirtualLab -AppGroup $AppGroup -Descri ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-VSBJob], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.AddVSBJob

Start-VSBJob : Cannot validate argument on parameter 'Job'. The argument is null. Provide a valid value for the argumen
t, and then try running the command again.
At C:\backup\dynamicvm.ps1:115 char:23
+     Start-VSBJob -Job $VsbJob
+                       ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Start-VSBJob], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVSBJob

Remove-VSBJob : Cannot validate argument on parameter 'Job'. The argument is null. Provide a valid value for the argume
nt, and then try running the command again.
At C:\backup\dynamicvm.ps1:118 char:24
+     Remove-VSBJob -Job (Get-VSBJob -Name $SbJobName) -Confirm:$false
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Remove-VSBJob], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.RemoveVSBJob

Remove-VSBApplicationGroup : Cannot validate argument on parameter 'AppGroup'. The argument is null. Provide a valid va
lue for the argument, and then try running the command again.
At C:\backup\dynamicvm.ps1:119 char:42
+ ... Group -AppGroup (Get-VSBApplicationGroup -Name $AppGroupName) -Confir ...
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Remove-VSBApplicationGroup], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.RemoveVSBApplicationGro
   up
Regards,

JLundgren
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

Hello,

if noone can give me a hint regarding the errors I get, any suggestions on where I can get help on this ?

Thanks in advance.

Regards
JLundgren
Regards,

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

Re: Surebackup verification - design.

Post by veremin »

Hashtable is a group of key/value pairs. Based on the error, it seems that you're trying to modify non-existent element (key argument is null), thus, the modification fails. Thanks!
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

Hello,

Thanks for your answer, Eremin.
I haven't altered the script. I am running it as is.
Should I configure something additional to make it work, besides having configured a VBR environment, vLab and run a backupjob ?

Regards,
JLundgren
Regards,

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

Re: Surebackup verification - design.

Post by veremin »

The script is rather old one, so chances are it needs to be modified to support your environment. But can you tell me whether there have been at least some VMs backed up within last 24 hours? Thanks!
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

In my test environment, I have run backup on 1 vm just before I exexute the script.
Could it be Powershell compatibility issues since I am using Server 2016 as a VBR server ?

Regards,
JLundgren
Regards,

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

Re: Surebackup verification - design.

Post by veremin »

Should be an issue, does running the following code returns anything:

Code: Select all

asnp VeeamPSSnapin
$Date = (get-date).AddDays(-30)
$VbrObjs = (Get-VBRBackupSession | ?{$_.JobType -eq "Backup" -and $_.EndTime -ge $Date}).GetTaskSessions() | ?{$_.Status -eq "Success" -or $_.Status -eq "Warning" }
$VbrObjs
Thanks!
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

I will test it when I am at my computer.
Thanks so far.

Regards,
JLundgren
Regards,

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

Re: Surebackup verification - design.

Post by veremin »

My assumption is that for some reason none of VMs backed up is returned by PS script as the result the following code gets $Null as parameter and thus fails. Thanks!
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

Hello,

here´s the result of the code you supplied me with:

Code: Select all

JobSess                 : Veeam.Backup.Core.CBackupSession
Info                    : Veeam.Backup.Model.CBackupTaskSessionInfo
ProgressManager         : Veeam.Backup.Core.CBackupTaskSessionProgress
WorkTimer               : Veeam.Backup.Core.CBackupTaskSessionWorkTimer
Id                      : b50973a3-9eeb-4fc8-8737-ce18da554fad
Name                    : DC1
Status                  : Success
Operation               : 
Progress                : Veeam.Backup.Model.CBackupProgressData
WorkDetails             : Veeam.Backup.Model.CBackupTaskWorkDetails
CurrentDiskNum          : 1
Logger                  : Veeam.Backup.Core.XmlLoggerCumulative
Tracer                  : Veeam.Backup.Core.CSessionLogTracer
WillBeRetried           : False
RetryCounter            : 0
IsFsAwareInfoLoadFailed : False
JobSessId               : 8972daf7-9d9c-4aae-85d4-ae3a8f52d9b6
JobName                 : Backup Job 1
TaskEventNotifier       : Veeam.Backup.Core.CEventNotifier
StopDetails             : 

JobSess                 : Veeam.Backup.Core.CBackupSession
Info                    : Veeam.Backup.Model.CBackupTaskSessionInfo
ProgressManager         : Veeam.Backup.Core.CBackupTaskSessionProgress
WorkTimer               : Veeam.Backup.Core.CBackupTaskSessionWorkTimer
Id                      : bfd94c14-e583-4d70-9de4-8a89076cbdde
Name                    : DC1
Status                  : Success
Operation               : 
Progress                : Veeam.Backup.Model.CBackupProgressData
WorkDetails             : Veeam.Backup.Model.CBackupTaskWorkDetails
CurrentDiskNum          : 1
Logger                  : Veeam.Backup.Core.XmlLoggerCumulative
Tracer                  : Veeam.Backup.Core.CSessionLogTracer
WillBeRetried           : False
RetryCounter            : 0
IsFsAwareInfoLoadFailed : False
JobSessId               : 80fdb3df-ce79-4fb1-bfdb-c801d029f7c7
JobName                 : Backup Job 1
TaskEventNotifier       : Veeam.Backup.Core.CEventNotifier
StopDetails             : 

JobSess                 : Veeam.Backup.Core.CBackupSession
Info                    : Veeam.Backup.Model.CBackupTaskSessionInfo
ProgressManager         : Veeam.Backup.Core.CBackupTaskSessionProgress
WorkTimer               : Veeam.Backup.Core.CBackupTaskSessionWorkTimer
Id                      : 1bab9a21-116b-4da7-8f05-9b33fe1e9b5b
Name                    : DC1
Status                  : Success
Operation               : 
Progress                : Veeam.Backup.Model.CBackupProgressData
WorkDetails             : Veeam.Backup.Model.CBackupTaskWorkDetails
CurrentDiskNum          : 1
Logger                  : Veeam.Backup.Core.XmlLoggerCumulative
Tracer                  : Veeam.Backup.Core.CSessionLogTracer
WillBeRetried           : False
RetryCounter            : 0
IsFsAwareInfoLoadFailed : False
JobSessId               : 2a3a3e31-d56e-4f3a-9c00-f8dd91f56632
JobName                 : Backup Job 1
TaskEventNotifier       : Veeam.Backup.Core.CEventNotifier
StopDetails             :
Regards,

JLundgren
JLundgren
Service Provider
Posts: 329
Liked: 30 times
Joined: Nov 13, 2015 10:00 am
Full Name: Johnny Lundgren
Contact:

Re: Surebackup verification - design.

Post by JLundgren »

Hello,

any comments on the result ?

Regards,

JLundgren
Regards,

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

Re: Surebackup verification - design.

Post by veremin »

The result looks OK to me. Then, you need to check test selectUntestedVMs function (preferably line by line) and see which one does not work - generates error, a variable does not get assigned, etc. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests