PowerShell script exchange
Post Reply
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

I am trying to set my VSS options to never truncate SQL transaction logs, my script runs okay with the parameter of $VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate".

And result shows that the transactions logs has been set to "NeverTruncate", as shown below:

PS C:\Users\anubhava\Desktop\Scripts for Demo> (Get-VBRJob -Name "Foundation DB Backup Job with PowerCLI" | Get-VBRJobVSSOptions).SqlBackupOptions

TransactionLogsProcessing : NeverTruncate
BackupLogsEnabled : False
NeverTruncateLogs : True
BackupLogsFrequencyMin : 15
UseDbBackupRetention : False
RetainDays : 15
ProxyAutoSelect : False
CredsId : 00000000-0000-0000-0000-000000000000

But, when I try to view the settings in GUI it somehow doesn't reflect as the SQL Backup settings are set to "Truncate Logs" instead of "Do not truncate".

Need help in disabling truncate logs option for SQL?
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by soncscy »

Hi Ankush,

Did you use the Set-VBRJobObjectVssOptions or Set-VBRJobVssoptions afterwards?

https://helpcenter.veeam.com/docs/backu ... ml?ver=110
https://helpcenter.veeam.com/docs/backu ... ml?ver=110

VSS can be set per object and I think a default job level option if I get it right, and it looks like you just updated the object in Powershell but never set the new value.

You can do this with the above cmdlets.
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

Hi Harvey,
Thanks for you reply. Below is my full script for VSS Options:

Code: Select all

# Set Application Awareness Settings for SQL:
Enable-VBRJobVSSIntegration -Job $Job
$Object = Get-VBRJob -Name "Foundation DB Backup Job with PowerCLI"
$VSSOptions = $Object.VssOptions
$VSSOptions.IgnoreErrors = $True
$VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate" 
#$VSSOptions.SqlBackupOptions.BackupLogsEnabled = $False
$VSSOptions.SqlBackupOptions.BackupLogsFrequencyMin = 15
$VSSOptions.SqlBackupOptions.UseDbBackupRetention = $False
$VSSOptions.SqlBackupOptions.RetainDays = 15
$VSSOptions.SqlBackupOptions.ProxyAutoSelect = $False
$VSSOptions.WinCredsId = "c16753ad-xxxx-xxxx-xxxx-eda0e629955f"

Set-VBRJobVssOptions -Job $Object -Options $VSSOptions
I have tried setting up the values to the object and it does passes it but somehow never reflects on GUI for the job.
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by soncscy »

Try using Get-VBRJobObject first on the job, and then Get and Set the JobObjectVSSOptions as shown above. Check the examples on the page.

(also, just FYI you don't need to blank out the UUIDs here :) Without access to your Veeam Environment, we have no way to associate the UUID with anything. UUIDs are based off of the content they represent, they're just a link)
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

HI Harvey,
Thanks for pointing out the UUID part :D

I tried using Get-VBRJobObject instead of Get-VBRJob but I used Get-VBRJob only because I am picking VMs from vCenter with Tags as VMs are segregated based on Tags and our backup policies are supposed to be defined that way.

Code: Select all

PS C:\Users\anubhava\Desktop\Scripts for Demo>  Get-VBRJobObject -Job "Foundation DB Backup Job with PowerCLI"

Name                      Type       ApproxSize       Location
----                      ----       ----------       --------
Foundation                Include    0 B              192.168.217.15\Service...

So I tried using your suggested method, but I get below error. I suppose the command is expecting an object to be a VM but in our case it is a Tag.

Code: Select all

PS C:\Users\anubhava\Desktop\Scripts for Demo> & '.\Create DB Backup Job - Foundation.ps1'

Job Name                  Type            State      Last Result  Description
--------                  ----            -----      -----------  -----------
Foundation DB Backup J... VMware Backup   Stopped    None         Created by Powershell at 16/09/2021 2:20:57 PM.
Foundation DB Backup J... VMware Backup   Stopped    None         Created by Powershell at 16/09/2021 2:20:57 PM.
Foundation DB Backup J... VMware Backup   Stopped    None         Created by Powershell at 16/09/2021 2:20:57 PM.
Foundation DB Backup J... VMware Backup   Stopped    None         Created by Powershell at 16/09/2021 2:20:57 PM.
Foundation DB Backup J... VMware Backup   Stopped    None         Created by Powershell at 16/09/2021 2:20:57 PM.

cmdlet Set-VBRJobObjectVssOptions at command pipeline position 1
Supply values for the following parameters:
Object: Foundation
Set-VBRJobObjectVssOptions : Cannot bind parameter 'Object'. Cannot convert the "Foundation" value of type "System.String" to type
"Veeam.Backup.Core.CObjectInJob".
At C:\Users\anubhava\Desktop\Scripts for Demo\Create DB Backup Job - Foundation.ps1:31 char:1
+ Set-VBRJobObjectVssOptions -Options $VSSOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-VBRJobObjectVssOptions], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Cmdlets.SetVBRJobObjectVssOptions

The changes I made to code is below:

Code: Select all

# Set Application Awareness Settings for SQL:
Enable-VBRJobVSSIntegration -Job $Job
$Object = Get-VBRJobObject -Job $job -name "Foundation"
$VSSOptions = $Object.VssOptions
$VSSOptions.IgnoreErrors = $True
$VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate" 
#$VSSOptions.SqlBackupOptions.BackupLogsEnabled = $False
$VSSOptions.SqlBackupOptions.BackupLogsFrequencyMin = 15
$VSSOptions.SqlBackupOptions.UseDbBackupRetention = $False
$VSSOptions.SqlBackupOptions.RetainDays = 15
$VSSOptions.SqlBackupOptions.ProxyAutoSelect = $False
$VSSOptions.WinCredsId = "c16753ad-595f-4113-9847-eda0e629955f"

Set-VBRJobObjectVssOptions -Options $VSSOptions
Kindly suggest how to move further. Thanks a lot for all the help you have giving!
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

I am still stuck with this issue, can someone please point to right direction?
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by soncscy »

Patience Ankush :) I do have a day job :D

> Get-VBRJob only because I am picking VMs from vCenter with Tags as VMs are segregated based on Tags and our backup policies are supposed to be defined that way.

This is why you're seeing some differences in expected behavior. Tags are hierarchy objects/containers, and they aren't parsed except at runtime for the job as best I know.

If you get the tag object, can't you set it there?

But for setting unique VMS beneath a container, as far as I'm aware there is no supported way to do this on powershell at the moment as the Set-VBRJobObjectVSSOptions cmdlet requires a job object; you can't get the VMs from the tag with the supported cmdlets. At best, you can set the changes on the tag object, but to set custom options for Tag objects you'll need to manually add the VMs in question.

As a workaround (I've not tried this), you might be able to use Add-VBRViJobObject: https://helpcenter.veeam.com/docs/backu ... ml?ver=110

This won't process the VM twice as best I know, it will simply allow you to set up specific VSS processing items and explicitly set VMs should take priority over the container.
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

Thanks Harvey for the response, will definitely have patience next time I raise a query. This was bit of urgent so had to bug you. :D

The workaround you suggested, Add-VBRViJobObject, actually would have worked fine if my backup job would have been based on VMs instead of tags. Since my backup job is based on tags my object has to be a Tag only.

Alternatively, I did try to use below code. Logging into my VC and then try gather list of VMs in particular Tag and passing it as an object for VSSOptions using foreach loop.

Code: Select all

# Logging into vCenter Server:
Connect-VIServer -Server iaashbngcvca001.ngcms.local -User anubhava -Password xxxxx

# Set Application Awareness Settings for SQL:
Enable-VBRJobVSSIntegration -Job $Job
$VMlist = Get-VM -Tag Foundation

foreach ($VM in $VMlist) {
$VSSOptions = Get-VBRJobObjectVssOptions -ObjectInJob $VM
$VSSOptions.IgnoreErrors = $True
$VSSOptions.SqlBackupOptions.TransactionLogsProcessing = "NeverTruncate" 
#$VSSOptions.SqlBackupOptions.BackupLogsEnabled = $False
$VSSOptions.SqlBackupOptions.BackupLogsFrequencyMin = 15
$VSSOptions.SqlBackupOptions.UseDbBackupRetention = $False
$VSSOptions.SqlBackupOptions.RetainDays = 15
$VSSOptions.SqlBackupOptions.ProxyAutoSelect = $False
$VSSOptions.WinCredsId = "c16753ad-595f-4113-9847-eda0e629955f"

Set-VBRJobObjectVssOptions -Options $VSSOptions -Object $VM
}
But this too doesn't seem working as Object for VSSOption should always be an object associated to the job. So I get below error, eventough my Tag should list the VMs associated but somehow it doesn't.

Code: Select all

PS C:\Users\anubhava\Desktop\Scripts for Demo> Get-VBRJobObjectVssOptions -ObjectInJob NGCMS-WIN-0336
Get-VBRJobObjectVssOptions : Cannot bind parameter 'ObjectInJob'. Cannot convert the "NGCMS-WIN-0336" value of type "System.String"
to type "Veeam.Backup.Core.CObjectInJob".
At line:1 char:41
+ Get-VBRJobObjectVssOptions -ObjectInJob NGCMS-WIN-0336
+                                         ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-VBRJobObjectVssOptions], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Cmdlets.GetVBRJobObjectVssOptions

PS C:\Users\anubhava\Desktop\Scripts for Demo>
I guess now only option is to manually change the value in the job created.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by oleg.feoktistov »

Hi Ankush,

I don't think that's the main cause of such behaviour. If you add tags as job objects, enable VSS options for them, but want to customize further VSS for individual tag members, you would need to add them separately as VSS objects, but you won't be able to delete initial tag from VSS as it is present as a job object. I assume the problem is that Add-VBRViJobObject cmdlet can add only job objects of type Include, but not of type VssChild, which in fact what your tag members will be as soon as you add them separately in Guest Processing Options. This is what I see in powershell once I added individual tag member in the UI:

Code: Select all

 Name                      Type       ApproxSize                   
----                      ----       ----------                    
Exchange.Server           VssChild   0 B              
SOBR                      Include    100.0 GB       
And with this code I am able to set individual options for VssChild member:

Code: Select all

$job = Get-VBRJob -Name 'Backup Job 1'
$objects = Get-VBRJobObject -Job $job -Name 'Exchange.Server'
$processingOptions = New-VBRJobVssOptions -ForObject
$processingOptions.SqlBackupOptions.TransactionLogsProcessing = 'NeverTruncate'
Set-VBRJobObjectVssOptions -Object $objects[0] -Options $processingOptions 

Hope it might be of any help,
Oleg
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

Thanks Oleg for your response!!

I guess for workaround we will have to add both the Tag and VMs in the the job. But only problem is if my environment scales up it will be very difficult to manually add VMs to the existing job. Picking VMs on basis of Tags eases up a lot of workload during automation.

If only there was any way to add VMs automatically to Backup Job identifying there Tags, we could have moved further. :(
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by oleg.feoktistov » 1 person likes this post

Thanks, Ankush! I noted this scenario for our internal feature enhancement discussions.
ankush_anubhav
Influencer
Posts: 10
Liked: never
Joined: Sep 15, 2021 7:04 am
Full Name: Ankush Anubhav
Contact:

Re: Set VSS options to never truncate SQL transaction logs

Post by ankush_anubhav »

Thanks Oleg that would be great!
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests