PowerShell script exchange
Post Reply
matteu
Veeam Legend
Posts: 821
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Tape scheduled

Post by matteu »

Hello,

How is it possible to get schedule of the tape jobs ?
I find it for incremental but not for monthly. I don't find anything to know if weekly / monthly is enabled on the Get-VBRTapeJob

I saw the attributes scheduledOptions.dailyOptions or gfsscheduleoptions

What I would like is :

Job1 : incremental monday and monthly 3rd wednesday
Job2 : incremental saturday no monthly
....
I don't know how to get the monthly part or GFS. Because for GFS all value are here even if they are not used. I don't find any property "enabled" to know if weekly is enabled or not.
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Tape scheduled

Post by david.domask »

Hi mattheu,

For the schedule items, can you maybe link to the user guide where you are looking? I suppose you mean about the Virtual Full schedule, but just want to be sure. If it is that, for backup to tape jobs it's stored under the FullBackupPolicy property:

Code: Select all

PS C:\Users\Administrator> $jobs[1].FullBackupPolicy

MonthlyOptions    Type WeeklyOnDays
--------------    ---- ------------
Third          Monthly {Saturday}


PS C:\Users\Administrator> $jobs[1].FullBackupPolicy.MonthlyOptions


Period           : 22:00:00
DayNumberInMonth : Third
DayOfWeek        : Wednesday
Months           : {January, February, March, April...}
DayOfMonth       : 1
But maybe you mean something else when you're talking about the incremental schedule?

For knowing if GFS is in use, check the FullBackupMediapool property and check its type:

Code: Select all

PS C:\Users\Administrator> $jobs.FullBackupMediapool


Capacity               : 12884901888
FreeSpace              : 5958008832
MediaSetCreationPolicy : Never
MediaSetName           : Media set # %id% %date%
MoveOfflineToVault     : False
RetentionPolicy        : Period
MultiStreamingOptions  : Veeam.Backup.PowerShell.Infos.VBRMultiStreamingOptions
Vault                  :
Worm                   : False
LibraryId              : 820415b7-4e6d-4599-8898-19a4a05a3b29
MoveFromFreePool       : False
Type                   : Custom  #Note the type here. Custom = Simple, Gfs = GFS, so you can just parse on Gfs
EncryptionOptions      : False
GlobalOptions          : Veeam.Backup.PowerShell.Infos.VBRGlobalMediaPoolOptions
Medium                 : {exam02L3, exam01L3, newt03L3}
Id                     : 94a5017e-794f-4601-b2b3-8fd10f9fa60a
Name                   : simple-media-pool
Description            : Created by DDOM-VEEAM-RB2\Administrator at 6/4/2020 20:51:32.
David Domask | Product Management: Principal Analyst
matteu
Veeam Legend
Posts: 821
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: Tape scheduled

Post by matteu »

Hello,

Thanks for the answer.
Sorry for the delay here too :( lot of work and too much busy these last days.

I have some backup to tape jobs and I would like to know when next run will be.
On some job, I have incremental + full but for other I have only full GFS.

What I would like is :

Test incremental is enabled : ???
Test full is enabled : ???

Name job = (Get-VbrTapeJob).name
Media pool name for Incr = (Get-VbrTapeJob).IncrementalBackupMediaPool.name (empty if disabled)
Media pool name for full = (Get-VbrTapeJob).FullBackupMediaPool.name
Schedule for Incr = (Get-VbrTapeJob).ScheduleOptions.DailyOptions.Period.hours (and minutes for exact time)
Schedulle for full = (Get-VbrTapeJob).ScheduleOptions.MonthlyOptions And here how could I know if I select Day of the month or Day of the weekd in GUI ?
Schedule for GFS = (Get-VbrTapeJob).GFSScheduleOptions How could I know what is enabled or not ?


Then I need the same for file to tape job

Test incremental is enabled : (Get-VbrTapeJob).IncrementalBackupPolicy.Enabled
Test full is enabled : (Get-VbrTapeJob).FullBackupPolicy.Enabled

Name job = (Get-VbrTapeJob).name
Media pool name for Incr = (Get-VbrTapeJob).IncrementalBackupMediaPool.name
Media pool name for full = (Get-VbrTapeJob).FullBackupMediaPool.name
Schedule for Incr = (Get-VbrTapeJob).IncrementalBackupPolicy.Type (and then I need to work on it)
Schedulle for full = (Get-VbrTapeJob).FullBackupPolicy.Type (and then I need to work on it)

VSS used or not = (Get-VbrTapeJob).UseVSS

I hope you could help me :)

Thanks
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Tape scheduled

Post by oleg.feoktistov »

Hi matteu,

Test incremental is enabled - take a look at (Get-VBRTapeJob).ProcessIncrementalBackups property.
Test full is enabled - well, we can't disable full backup policy for backup to tape jobs, can we?
(Get-VbrTapeJob).ScheduleOptions.MonthlyOptions, day of a month or week - I'm gonna go ahead and guess that you are talking about the case when your backup to tape job is targeted to a GFS media pool. In other scenarios you can't really select just any day of a month. If it is GFS, you are actually after GFSScheduleOptions.MonthlyOptions. There you need to look at Kind property:

Code: Select all

PS C:\Users\Administrator\Documents> $job.GFSScheduleOptions.MonthlyOptions

      Kind DayOfWeek DayOfWeekNumber DayOfMonth
      ---- --------- --------------- ----------
DayOfMonth    Sunday           First 15  
(Get-VbrTapeJob).GFSScheduleOptions, enabled or not - GFS options are enabled on a media pool level, so you need to query target GFS media pool for that. I usually use this kind of script:

Code: Select all

$job = Get-VBRTapeJob -Name 'Backup to Tape Job 1'
$gfsPool = Get-VBRTapeMediaPool -Id $job.FullBackupMediaPool.Id
if ($gfsPool.Type -eq 'GFS') {
  $isGFS = $true
}
else {
  $isGFS = $false
}
$dailyPeriod = $gfsPool.DailyMediaSetOptions.OverwritePeriod
$weeklyPeriod = $gfsPool.WeeklyMediaSetOptions.OverwritePeriod
$monthlyPeriod = $gfsPool.MonthlyMediaSetOptions.OverwritePeriod
$quarterlyPeriod = $gfsPool.QuarterlyMediaSetOptions.OverwritePeriod
$yearlyPeriod = $gfsPool.YearlyMediaSetOptions.OverwritePeriod

if ($dailyPeriod -ne 0) {
  $dailyEnabled = $true
}

else {
  $dailyEnabled = $false
}

if ($weeklyPeriod -ne 0) {
  $weeklyEnabled = $true
}

else {
  $weeklyEnabled = $false
}

if ($monthlyPeriod -ne 0) {
  $monthlyEnabled = $true
}

else {
  $monthlyEnabled = $false
}

if ($quarterlyPeriod -ne 0) {
  $quarterlyEnabled = $true
}

else {
  $quarterlyEnabled = $false
}

if ($yearlyPeriod -ne 0) {
  $yearlyEnabled = $true
}

else {
  $yearlyEnabled = $false
}

$job | select Name, @{n='IsGFS';e={$isGFS}}, @{n='DailyEnabled';e={$dailyEnabled}}, `
@{n='WeeklyEnabled';e={$weeklyEnabled}}, @{n='MonthlyEnabled';e={$monthlyEnabled}}, ` 
@{n='QuarterlyEnabled';e={$quarterlyEnabled}}, @{n='YearlyEnabled';e={$yearlyEnabled}}
I didn't really recognize any questions regarding file to tape jobs in your post. I went to double check the properties you mentioned anyways - they are working correctly.

Let me know if you need any further help on this.

Thanks,
Oleg
matteu
Veeam Legend
Posts: 821
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: Tape scheduled

Post by matteu »

Thanks for your answer.

I'm sorry, I don't know well tapes jobs.

What I see :

When using GFS media pool, there is not incremental backup possible. It's only for full.
When using standard media pool, I can use (Get-VBRTapeJob).ProcessIncrementalBackup

You're right, full will happen if backup job is full but if not, it's virtual synthetic full days. (I need to test it)

For file to tape, it seems OK yes :)

OK, I need to work on it and I will come to past my function.
matteu
Veeam Legend
Posts: 821
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: Tape scheduled

Post by matteu »

I worked on it but I don't find this :

I would like for file to tape to obtain exactly schedule for full backup.
If I select I want full backup monthly 18h00 four wednesday I can't find wednesday on properties object. the value is always saturday

$a=Get-VBRTapeJob | where {$_.type -eq "filetotape"}
$a.FullBackupPolicy.monthlyoptions


My actual function :

Code: Select all

function Get-VeeamBackupTape
{
    Write-host "Veeam backup to tape job"
    $BackupTapeJobsReq = Get-VBRTapeJob
    foreach ($element in $BackupTapeJobsReq)
    {
        if ($element.type -eq "BackupToTape")
        {
            If ($element.ProcessIncrementalBackup)
            {
                $IncrementalMediaPool = $element.IncrementalBackupMediaPool.Name
            }
            else
            {
                $IncrementalMediaPool = "<N/A>"
            }
            if($element.ScheduleOptions.Enabled)
            {
                $ScheduleD = "A la main"
                $ScheduleF = "A la main"
            }
            else
            {
                $ScheduleD = "Not scheduled"
                $ScheduleF = "Not scheduled"
            }
            $VirtualSyntheticFull = $element.fullbackuppolicy.weeklyondays -join ","
        }
        elseif ($element.type -eq "FileToTape")
        {
            
            if($element.IncrementalBackupPolicy.Enabled -eq $true)
            {
                $ScheduleD = $element.IncrementalBackupPolicy.DailyOptions.Period.ToString() + " " + $element.IncrementalBackupPolicy.DailyOptions.type
            }
            else 
            {
                $ScheduleD = "<N/A>"
            }
            if($element.FullBackupPolicy.Enabled)
            {
                if ($element.FullBackupPolicy.type -eq "Daily")
                {
                    $ScheduleF = $element.FullBackupPolicy.DailyOptions.Period.ToString() + " " + $element.FullBackupPolicy.DailyOptions.type
                }
                else
                {
                    $ScheduleF = $element.FullBackupPolicy.MonthlyOptions.Period.ToString() + " Monthly " + $element.FullBackupPolicy.MonthlyOptions.Month -join "`t"
                }
            }

            $VirtualSyntheticFull = "<N/A>"
        }
        else 
        {
            write-host "Unknown Type" -ForegroundColor Red
        }
        if ($element.GFSScheduleOptions -ne $null)
        {
            $weeklyPeriod = $element.fullbackupmediapool.WeeklyMediaSetOptions.OverwritePeriod
            $monthlyPeriod = $element.fullbackupmediapool.MonthlyMediaSetOptions.OverwritePeriod
            $quarterlyPeriod = $element.fullbackupmediapool.QuarterlyMediaSetOptions.OverwritePeriod
            $yearlyPeriod = $element.fullbackupmediapool.YearlyMediaSetOptions.OverwritePeriod
            $GFSBackup = [string] $weeklyPeriod + "W/" + $monthlyPeriod + "M/" + $quarterlyPeriod + "Q/" + $yearlyPeriod +"Y"
            
            $GFSDailyScan = $element.gfsscheduleoptions.dailyoptions.startat.tostring()
        }
        else
        {
            $GFSBackup = "<N/A>"
            $GFSDailyScan = "<N/A>"
        }
        [pscustomobject]@{
            Name = $element.Name
            Description = $element.Description
            IncrementalMediaPool = if ($IncrementalMediaPool) {$IncrementalMediaPool} else {"<N/A>"}
            VirtualSyntheticFull = $VirtualSyntheticFull
            FullMediaPool = $element.FullBackupMediaPool.name
            GFSDailyScan = $GFSDailyScan
            GFSBackup = $GFSBackup
            EjectMedia = $element.EjectCurrentMedium
            ExportMediaSet = $element.ExportCurrentMediaSet
            ScheduleD = $ScheduleD
            ScheduleF = $ScheduleF
        }
    }
    Write-host "-------------------"
}
To be honest, I find really hard how to get scheduled jobs with veeam and powershell. It's a lot of possibilities (everydays, selected day, weekly, after this job, each 2 hours, ... )
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Tape scheduled

Post by david.domask »

Hey matteu,
If I select I want full backup monthly 18h00 four wednesday I can't find wednesday on properties object. the value is always saturday
Can you show the output you get and what version you're on? I just made a quick test job and checking FullBackupPolicy.MonthlyOptions shows me the updated day:

Code: Select all

PS C:\Users\Administrator> $tjob.FullBackupPolicy.MonthlyOptions
Period           : 22:00:00
DayNumberInMonth : Fourth
DayOfWeek        : Thursday
Months           : {January, February, March, April...}
DayOfMonth       : 1
In fully patched v11a it's working for me.

I get it's a bit of busy-work to build the initial function, but maybe there are some ways to consolidate some of the other items to get fed into the same function.

You might reduce some of your code clutter by setting the default for a lot of these variables to their "N/A" value you decide, and then just drop the else-statements. It will shorten a lot of your writing and make it a bit easier to read and maybe seem a bit more manageable.
David Domask | Product Management: Principal Analyst
matteu
Veeam Legend
Posts: 821
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: Tape scheduled

Post by matteu »

Hello
I ll try to check again tomorow...

I know i m up to date.

What do you mean for n/a ?

Initialize the variable at start to n/a value and omit the else statement right ?

I m not powershell developer and I m learning it myself so if you have other advices it s a good way for me to improve my knowledge :)
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Tape scheduled

Post by david.domask »

> Initialize the variable at start to n/a value and omit the else statement right ?

Exactly. Right now you're doing a ton of:

If(Thing) {
$value = something
} else {
$value = "N/A"

It's not "bad" ,but when you have 5+ of those stacked up, I just find it distracting.

Instead, why not just do:

$value1 = "N/A"
$value2 = "N/A"

And later on you can just do:

if(Thing) { $value1 = something }

and it's a lot cleaner to read and you don't need to do all the extra script blocks and else statements.
David Domask | Product Management: Principal Analyst
matteu
Veeam Legend
Posts: 821
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: Tape scheduled

Post by matteu »

Good advice :) I need to update my script with this advice (and not only this one ^^ )
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests