PowerShell script exchange
Post Reply
alex.nunley
Influencer
Posts: 19
Liked: never
Joined: Jan 18, 2013 3:36 pm
Full Name: Alex Nunley
Contact:

Enable / Disable Periodic active full backup

Post by alex.nunley »

So I am trying, fruitlessly, to go through a csv of jobs, and enable Full Backups. I can modify the schedule of the backup, but I cannot enable the fullbackup for all the jobs. Lots of them fail, saying there is no setting available to be set. Code snippet below. Am I using an incorrect method? Why does it work for some but not all?

Code: Select all

$backups = Import-csv "backup-list.csv"
foreach ($i in $backups){
$JobName = $i.VM
$job = Get-VBRJob -Name $JobName
$opt = Get-VBRJobOptions $job
$opt.BackupTargetOptions.FullBackupDays = "Friday" #Set the date for periodic full backups
$opt.Options.RootNode.EnableFullBackup = "True" #Enable Full Backup?
alex.nunley
Influencer
Posts: 19
Liked: never
Joined: Jan 18, 2013 3:36 pm
Full Name: Alex Nunley
Contact:

Re: Enable / Disable Periodic active full backup

Post by alex.nunley »

This is how I set their days and whatnot, it works fine.

Code: Select all

$JobOptions.BackupTargetOptions.Algorithm = "Syntethic"
$JobOptions.BackupTargetOptions.TransformIncrementsToSyntethic = "False"
$JobOptions.BackupTargetOptions.FullBackupScheduleKind = "Daily"
$JobOptions.BackupTargetOptions.FullBackupDays = "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"
But I cannot figure out how to actually enable this setting.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Enable / Disable Periodic active full backup

Post by Sethbartlett »

There should already be a post from me somewhere on this forum about this. You also need to change a scheduling option to true I believe. I believe there is a settings under .Options for basically "Enabling" the job scheduling.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
alex.nunley
Influencer
Posts: 19
Liked: never
Joined: Jan 18, 2013 3:36 pm
Full Name: Alex Nunley
Contact:

Re: Enable / Disable Periodic active full backup

Post by alex.nunley »

I think we're going in opposite directions on this one. I have the "Job Scheduling" setup the way I want, to run every friday. That works fine.

I am looking at the scheduling options for Active Full Backup. This does not appear to be affected at all by the scheduling options.

a screen of the gui.

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

Re: Enable / Disable Periodic active full backup

Post by veremin »

Hi, Alex.

It seems to me that you’ve missed a very crucial line in the code provided above. The one which would be responsible for setting given options.

Try to modify your code as shown in the following example and see whether it helps. Pay special attention to the last line:

Code: Select all

$backups = Import-csv "backup-list.csv"
foreach ($i in $backups){
$JobName = $i.VM
$job = Get-VBRJob -Name $JobName
$opt = Get-VBRJobOptions $job
$opt.BackupTargetOptions.FullBackupDays = "Friday"
$opt.Options.RootNode.EnableFullBackup = "True" 
Set-VBRJobOptions -job $job -options $opt 
Hope this helps.
Thanks.
alex.nunley
Influencer
Posts: 19
Liked: never
Joined: Jan 18, 2013 3:36 pm
Full Name: Alex Nunley
Contact:

Re: Enable / Disable Periodic active full backup

Post by alex.nunley »

Thanks for your input. That line was not included in my post, but does exist in the script I have been working on.

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

Re: Enable / Disable Periodic active full backup

Post by veremin »

So, correct me if I’m wrong, but you’re trying to go through job stored in .csv-file and enable Full Backup for all of them. And the problem is that for some of them it works smoothly and for some it fails with “no setting available” error, right?

If so, I’d say that this issue might be related to these lines:

Code: Select all

$JobName = $i.VM
$job = Get-VBRJob -Name $JobName
Are you 100% sure that .VM parameter always coincides with the corresponding name of your job?

My assumption is that in some cases .VM parameter may differ from the real job name. In other words, there is no job with such name, so, sometimes $job variable is specified as “0” value, and as a result you see errors regarding methods that cannot be found on this object. (like in your previous script)

Consequently, if I were you, I’d definitely start my investigation with it.

Hope this helps.
Thanks.
alex.nunley
Influencer
Posts: 19
Liked: never
Joined: Jan 18, 2013 3:36 pm
Full Name: Alex Nunley
Contact:

Re: Enable / Disable Periodic active full backup

Post by alex.nunley »

Yes, I am sure that the .VM parameter coincides, as the same CSV, and thus the same .VM parameter, was used to Create the Jobs in question.
alex.nunley
Influencer
Posts: 19
Liked: never
Joined: Jan 18, 2013 3:36 pm
Full Name: Alex Nunley
Contact:

Re: Enable / Disable Periodic active full backup

Post by alex.nunley »

I do not know why, but this works one directionally. I used it to turn it on, but to test, I wanted to turn it back off. It wont. Le sigh. But I have what I wanted.

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
$backups = Import-csv "c:\temp\list.csv"
foreach ($i in $backups){
$JobName = ($i.VM)
$Job = Get-VBRJob -Name $JobName
$JobOptions = Get-VBRJobOptions $Job
$JobOptions.BackupStorageOptions.EnableFullBackup = $true
Set-VBRJobOptions $Job -Options $JobOptions
}
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enable / Disable Periodic active full backup

Post by veremin »

I’ve tested both of the provided code examples (with .rootnode and .BackupStorageOption) and everything seems to work properly in both directions (EnableFullBackup – True, False).

So, it’s probably something related particularly to your case. Although you’ve said that were no problems with import-csv, I’d still doublecheck that, since everything apart from this method is supposed to work like a charm.

Additionally, it might be worth replacing import-csv line with Get-VBRJob method coming with necessary parameters, like type specification or whatever, and see whether it works.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests