PowerShell script exchange
Post Reply
mgratla
Influencer
Posts: 19
Liked: never
Joined: Feb 04, 2014 11:13 pm
Full Name: Mark
Contact:

Set VSS options for each machine in a job

Post by mgratla »

I've got a script worked out for creating jobs, but I need to set VSS options if the job contains a machine with a name that contains SQL

What I have to get the jobs into an array and parse them, is this

Code: Select all

$VSSARRAY = Get-VBRJob -Name $JobName | Get-VBRJobObject

foreach $_.name in $VSSARRAY { {if $_.Name -Like "*SQL*} {/code]

And here's where I'm stuck. Most of the commands seem to indicate that you'll set it for the entire job, but I want to set each SQL machine as "Ignore processing failures" and "do not truncate logs"

Can anyone assist?
mgratla
Influencer
Posts: 19
Liked: never
Joined: Feb 04, 2014 11:13 pm
Full Name: Mark
Contact:

Re: Set VSS options for each machine in a job

Post by mgratla »

Tried the following

Code: Select all

$Vbrvssoptions = New-VBRJobVssOptions
$Vbrvssoptions.Enabled =$True
$Vbrvssoptions.IgnoreErrors =$True
$Vbrvssoptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate"
$vbrvssoptions.ExchangeBackupOptions.TransactionLogsProcessing = "TruncateOnlyOnSuccessJob"

$vbrnovssoptions = New-VBRJobVssOptions
$vbrnovssoptions.Enabled =$false

#$vsscredopt = Get-VBRJob -Name $jobname | Get-VBRJobVSSOptions
#$vsscredopt.WinCredsId = MYGUID

$Vssarray = Get-VBRJob -name $Jobname | Get-VBRJobObject

foreach ($Name in $VSSARRAY | where {$_.Name -Like "*-SQL-*"}) { Get-VBRJob -Name $Jobname | Get-VBRJobObject -Name $name | Set-VBRJobVssOptions -Options $VBRVSSOptions }
But this returns a very... weird error

Code: Select all

Get-VBRJobObject : The specified wildcard pattern is not valid: Id: [bbdd7fdd-4043-4e6a-8b91-9a7e11ed0486], ObjectId: [4519b933-9664-4785-8a24-e722ae9be9fc], JobId: [a7dc651b-f546-4ba2-8c38-2f558e8b12e1]FolderId: [00000000-0000-0000-0000-000000000000]
Location: [Pathinsidevcenter], Type: [Include], ApproxSize: [90040535724]
VssOptions: [VssSnapshotOptions: [Enabled: [True], IgnoreErrors: [False], IsCopyOnly: [False]], WinGuestFSIndexingOptions: [Type: [ExceptSpecifiedFolders], IncludedFolders: [], ExcludedFolders: [%windir%; %ProgramFiles%; %ProgramFiles(x86)%; 
%ProgramW6432%; %TEMP%]], LinGuestFSIndexingOptions: [Type: [ExceptSpecifiedFolders], IncludedFolders: [], ExcludedFolders: [/cdrom; /dev; /media; /mnt; /proc; /tmp; /lost+found]], SqlBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob], 
BackupLogsFrequencyMin: [15], UseDbBackupRetention: [True], RetainDays: [15], ProxyAutoSelect: [True]], ExchangeBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob]], WinCredsId: [00000000-0000-0000-0000-000000000000], LinCredsId: 
[00000000-0000-0000-0000-000000000000], Old Properties: [Enabled: [True], IgnoreErrors: [False], GuestFSIndexingType: [ExceptSpecifiedFolders], IncludedIndexingFolders: [], ExcludedIndexingFolders: [%windir%; %ProgramFiles%; %ProgramFiles(x86)%; 
%ProgramW6432%; %TEMP%], LinGuestFSIndexingType: [ExceptSpecifiedFolders], LinIncludedIndexingFolders: [], LinExcludedIndexingFolders: [/cdrom; /dev; /media; /mnt; /proc; /tmp; /lost+found], IsFirstUsage: [True]]], 
Platform: [EVmware], UpdateVmx: [True]
DiskFilter: [Ver8|3000;3001;3002;3003;2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2036;2037;2038;2040;2041;2042;2043;2044;2045;2046
;2047;2048;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;2061;2062;2063;16000;16001;16002;16003;16004;16005;16006;16008;16009;16010;16011;16012;16013;16014;16015;16016;16017;16018;16019;16020;16021;16022;16023;16024;16025;16026;16027;16028;16029;16
030;16031;16032;16033;16034;16035;16036;16038;16039;16040;16041;16042;16043;16044;16045;16046;16047;16048;16049;16050;16051;16052;16053;16054;16055;16056;16057;16058;16059;16060;16061;16062;16063;16064;16065;16066;16068;16069;16070;16071;16072;16073;16074;1
6075;16076;16077;16078;16079;16080;16081;16082;16083;16084;16085;16086;16087;16088;16089;16090;16091;16092;16093;16094;16095;16096;16098;16099;16100;16101;16102;16103;16104;16105;16106;16107;16108;16109;16110;16111;16112;16113;16114;16115;16116;16117;16118;
16119], 
At line:1 char:94
+ ... ame $Jobname | Get-VBRJobObject -Name $name | Set-VBRJobVssOptions -Options $VBR ...
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-VBRJobObject], WildcardPatternException
    + FullyQualifiedErrorId : RuntimeException,Veeam.Backup.PowerShell.Command.GetVBRJobObject
 
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set VSS options for each machine in a job

Post by veremin »

The following example shows how to set the required settings for job object named SQLServer that is present inside "SQL Backup" Job. It shouldn't be that difficult to make the script set VSS options for all job objects which names contain "SQL":

Code: Select all

$Job = Get-VBRJob -Name "SQL Backup"
$Object = $Job | Get-VBRJobObject | ?{$_.name -eq "SQLServer"}
$VSSOptions = $Object.VssOptions
$VSSOptions.IgnoreErrors = $True
$VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate"
$Object.SetVssOptions($VSSOptions)
Thanks.
Dario.Palmisano
Enthusiast
Posts: 31
Liked: 2 times
Joined: Nov 11, 2013 7:22 am
Full Name: Dario Palmisano
Contact:

[MERGED] : Set job VSS as "Ignore Failures"

Post by Dario.Palmisano »

Hello,

I would like to set with powershell, the Application-aware VSS parameter for a Job as "Ignore Failures" (Try application processing, but ignore failures).

How is it possible?

Thanks

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

Re: Set VSS options for each machine in a job

Post by veremin »

Hi, Dario,

Kindly, check the post provided above; should be exactly what you're looking for.

Thanks.
Dario.Palmisano
Enthusiast
Posts: 31
Liked: 2 times
Joined: Nov 11, 2013 7:22 am
Full Name: Dario Palmisano
Contact:

Re: Set VSS options for each machine in a job

Post by Dario.Palmisano »

Thanks,

if I set IgnoreErrors = $True and then access the Application-aware page of the user interface, I still see the Require success.

Is it an interface refresh problem or what?

Thanks and regards
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set VSS options for each machine in a job

Post by veremin »

This setting is object specific. So, did you set it up for a particular VM present inside a job?

Code: Select all

$Object = $Job | Get-VBRJobObject | ?{$_.name -eq "Name of VM you want to setup the setting for"}
Thanks.
Dario.Palmisano
Enthusiast
Posts: 31
Liked: 2 times
Joined: Nov 11, 2013 7:22 am
Full Name: Dario Palmisano
Contact:

Re: Set VSS options for each machine in a job

Post by Dario.Palmisano »

Now I got it!

The settings regards the VM not the job (maybe not well expressed, but it works!)

Many thanks

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

Re: Set VSS options for each machine in a job

Post by veremin »

The settings regards the VM not the job.
Correct.

If you want to set this setting for all VMs, you should create a loop similar to the following:

Code: Select all

$Job = Get-VBRJob -Name "Name of Job"
foreach ($Object in ($Job | Get-VBRJobObject))
{
$VSSOptions = $Object.VssOptions
$VSSOptions.IgnoreErrors = $True
$Object.SetVssOptions($VSSOptions)
}
Thanks.
ivarson
Lurker
Posts: 1
Liked: never
Joined: Jan 29, 2018 9:33 pm
Full Name: joel ivarson
Contact:

[MERGED] Change default SqlLogBackup for entire job

Post by ivarson »

So our DBA's decided they want all SQL logs backed up every 60th minute, retained for 7 days.

I made a script earlier to have a VM added to the specific SQL-job, but by default Veeam truncates the logs, so we have to enter the B&R console to edit every single item after adding them. (or changing it for multiple vms at once, but still an additional step)

Can I set this via powershell?
Either change the default settings for the job or atleast scripting it for the specific VM being added.
https://helpcenter.veeam.com/docs/backu ... tml?ver=95

Code: Select all

PS > (New-VBRJobOptions -ForBackupJob).sqllogbackupoptions

StorageIntervalValue : 1
StorageIntervalUnit  : Hour
BackupIntervalValue  : 3
BackupIntervalUnit   : Minute
RetentionType        : PerOib
DailyRetentionDays   : 14
can this be used to change how VMs gets their transactions logged backup up, if so, will I affect every single option for the job with this?
the property Sqllogbackupoptions is readonly for the job itself so appearently you have to set all options at once?
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Set VSS options for each machine in a job

Post by PTide »

Hi Joel,

Please check Vladimir's post.

Thanks
Meirp
Novice
Posts: 3
Liked: never
Joined: Dec 06, 2020 2:48 pm
Full Name: Meir Peleg
Contact:

[MERGED] Chanage application ware powershell

Post by Meirp »

Hi Guys,

i use this code for change 'IgnoreErrors' on application aware.

Code: Select all

$Job = Get-VBRJob -Name  $VeeamJobs
$Object = $Job | Get-VBRJobObject -Name  $VeeamJobs
$VSSOptions = $Object.VssOptions
$VSSOptions.IgnoreErrors = $True
$VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate"
$Object.SetVssOptions($VSSOptions)
How ever, I want to change to this option

"Try application processing , but ignore failures", and on trunk "process truncation logs with this job (recommended).

Can you assist with the right value?
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Set VSS options for each machine in a job

Post by Natalia Lupacheva »

Hi Meir,

moved your post to the existing thread to keep these questions in one place.
Please take a look at the discussions above, might give you a hint.

Thanks!
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Set VSS options for each machine in a job

Post by jhoughes »

Also, if you can't determine the values, I always recommend creating a test job as you want specific options to be set, then investigate those settings with PowerShell.

It's much quicker to find the specific settings that way.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
collinp
Expert
Posts: 230
Liked: 13 times
Joined: Feb 14, 2012 8:56 pm
Full Name: Collin P
Contact:

Re: Set VSS options for each machine in a job

Post by collinp »

What am I doing wrong here? I have a VMWare job and I'm trying to set the SQL logs to not truncate and BackupLogsFrequency to 60 min via powershell. After running the suggested code, it still shows "TruncateOnlyOnSuccessJob" and 15 minutes for frequency

$Job = Get-VBRJob -Name "VMWareJob1"
$Object = $Job | Get-VBRJobObject | ?{$_.name -like "*SQL*"}

write-host $Object.name
SQLServer1

$VSSOptions = $Object.VssOptions
$VSSOptions.IgnoreErrors = $True
$VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate"
$VSSOptions.SqlBackupOptions.BackupLogsFrequencyMin = 60
$Object.SetVssOptions($VSSOptions)

(get-vbrjobvssoptions -job $job).sqlbackupoptions
TransactionLogsProcessing : TruncateOnlyOnSuccessJob
BackupLogsEnabled : False
NeverTruncateLogs : False
BackupLogsFrequencyMin : 15
UseDbBackupRetention : True
RetainDays : 15
ProxyAutoSelect : True
CredsId : 00000000-0000-0000-0000-000000000000
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Set VSS options for each machine in a job

Post by jhoughes »

You are setting the job object VSS options, but then displaying the job VSS options afterwards.

Which are your trying to edit & confirm?
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
Post Reply

Who is online

Users browsing this forum: ekulaga and 20 guests