Get Backup Job Schedule and Repository

PowerShell script exchange

Get Backup Job Schedule and Repository

Veeam Logoby rsarnold1s » Mon Aug 29, 2016 10:20 pm

Hi All-

Our IT Team has an intranet site that I am currently writing documentation for. What I am doing is creating a html table that will show job name, vms in job, job schedule and job repository. So far I have a simple script that lists jobs and vms in job:
Code: Select all
Add-PSSnapin VeeamPSSnapin
Connect-VBRServer -Server MyServer
$Jobs = Get-VBRJob
Foreach($Job in $Jobs)
{
    $JobName = $Job.Name
    $Objects = $Job.GetObjectsInJob()
    $Objects.Name
    $JobName

}
Disconnect-VBRServer


I have been messing around with Get-VBRJobScheduleOptions, but it doesn't look good when displayed in a table. All I want to get is the days that the job runs and also the backup repository. Is there an easy way to do this?
rsarnold1s
Influencer
 
Posts: 11
Liked: never
Joined: Thu May 05, 2016 10:33 pm

Re: Get Backup Job Schedule and Repository

Veeam Logoby v.Eremin » Tue Aug 30, 2016 10:54 am

Do all jobs have more or less similar scheduler (like, daily, monthly with active full scheduled for particular day, etc.)? If yes, which one?

I'm wondering because having similarities in schedules should make a potential script simpler.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get Backup Job Schedule and Repository

Veeam Logoby rsarnold1s » Tue Aug 30, 2016 2:25 pm

Yes, all jobs are either daily or weekly at the moment.
rsarnold1s
Influencer
 
Posts: 11
Liked: never
Joined: Thu May 05, 2016 10:33 pm

Re: Get Backup Job Schedule and Repository

Veeam Logoby v.Eremin » Wed Aug 31, 2016 10:01 am

Try the following example and see whether it answers your requirements:

Code: Select all
Get-VBRJob | where {$_.JobType -eq "Backup"} | Select-Object -Property @{N="Name";E={$_.Name}}, @{N="Schedule Type";E={$_.ScheduleOptions.OptionsDaily.kind}}, @{N="Scheduled Days";E={$_.ScheduleOptions.OptionsDaily.DaysSrv}}, @{N="Scheduled Days";E={$_.ScheduleOptions.OptionsDaily.DaysSrv}}   


Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get Backup Job Schedule and Repository

Veeam Logoby rsarnold1s » Wed Aug 31, 2016 6:38 pm

Thanks Eremin, I was able to get it to work in the Powershell console.

Code: Select all
Add-PSSnapin VeeamPSSnapin
Connect-VBRServer -Server myserver
$Jobs = Get-VBRJob
Foreach($Job in $Jobs)
{
    $JobName = $Job.Name
    $Objects = $Job.GetObjectsInJob()
    $RestorePoints = Get-VBRRestorePoint -Backup $JobName
    $Day = $Job.ScheduleOptions.OptionsDaily.DaysSrv
   
    $RP = $RestorePoints.Count
    $VM = $Objects.Name
   
    $Body += "<tr>"
    $Body += "<td>$JobName</td>"
    $Body += "<td>$VM</td>"
    $Body += "<td>$RP</td>"
    $Body += "<td>$Day</td>"
    $Body += "</tr>"

}
Disconnect-VBRServer

Return $Body


Just a couple more questions:

1. My web server is using WAMP 32-bit and it looks like the Veeam PS module is 64-bit. How can I get this module registered for 32-bit?
2. I've been looking but haven't found a command that shows the time when the backup starts. Can you direct me to the correct resource?

Again, thank you.
rsarnold1s
Influencer
 
Posts: 11
Liked: never
Joined: Thu May 05, 2016 10:33 pm

Re: Get Backup Job Schedule and Repository

Veeam Logoby rsarnold1s » Wed Aug 31, 2016 9:42 pm

Just an update, been messing around with different commands and have found something that is working pretty well at the moment.
Code: Select all
$Session = New-PSSession -ComputerName myserver
    Invoke-Command -Session $Session -ScriptBlock{
        Add-PSSnapin VeeamPSSnapin
        $VbrJobs = Get-VBRJob | Sort-Object typetostring, name
        $Repos = Get-VBRBackupRepository
       
        Foreach($Job in $VbrJobs)
        {
            #Get Job Name
            $JobName = $Job.Name
           
            #Get VMs in Job
            $Objects = $Job.GetObjectsInJob()

            #Get Restore Points
            $RP = $Job.GetOptions().backupstorageoptions.retainCycles

            #Get Days
            $Day = $Job.ScheduleOptions.OptionsDaily.DaysSrv
            $Freq = $Job.ScheduleOptions.OptionsDaily.kind

            If($Freq -eq "Everyday")
            {
                $Day = "Everyday"
            }

            #Get Backup Repository Name
            $RepoTarget = $Job.FindTargetRepository()
            $RepoTarget = $RepoTarget.Name
           
            #Get VM Name   
            $VM = $Objects.Name

            #Get Last Backup
            $Backup = Get-VBRBackup | Where{$_.JobName -eq "$JobName"}
            $LastBackup = $Backup.LastPointCreationTime
                 
   
            $Body += "<tr>"
            $Body += "<td>$JobName</td>"
            $Body += "<td>$VM</td>"
            $Body += "<td>$RP</td>"
            $Body += "<td>$Day</td>"
            $Body += "<td>$RepoTarget</td>"
            $Body += "<td>$LastBackup</td>"
            $Body += "</tr>"


        }
   
    Return $Body
}


This is a work-around for my WAMP server trying to run Powershell in 32-bit mode, but using the Invoke-Command method I get flooded with "WARNING: You should update your PowerShell to PowerShell 2.0 version" messages. My OS is server 2012 running Powershell v5. Anyway to prevent those messages?
rsarnold1s
Influencer
 
Posts: 11
Liked: never
Joined: Thu May 05, 2016 10:33 pm

Re: Get Backup Job Schedule and Repository

Veeam Logoby v.Eremin » Thu Sep 01, 2016 9:54 am

Just to confirm - you're executing the script on a machine running 32-bit OS and, thus, getting tons of the said warnings? Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get Backup Job Schedule and Repository

Veeam Logoby rsarnold1s » Thu Sep 01, 2016 4:48 pm

Sorry, should have been more specific on my environment.

OS: Server 2012 64-bit Powershell v5 installed
WAMP 32-bit is installed on the server.
Processes are run as 32-bit from the WAMP web server. Looks like the Veeam Powershell module is 64-bit only, as a work-around I used the Invoke-Command to connect to my Veeam server to run the command.
However, here is a sample output I am getting using the code posted above. The script works fine, it's just that these warnings appear before any data is output.
Code: Select all
PS C:\Windows\system32> C:\Veeam.ps1
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.


Normally the warnings wouldn't be an issue, but this is displayed on my web report:

Image

I think this issue could be resolved if I could register the Veeam PS module for 32-bit so I don't have to use the Invoke-Command method. Do you know if this is possible?
rsarnold1s
Influencer
 
Posts: 11
Liked: never
Joined: Thu May 05, 2016 10:33 pm

Re: Get Backup Job Schedule and Repository

Veeam Logoby v.Eremin » Thu Sep 01, 2016 8:48 pm

I don't think at is, since PS snap-in in now a part of VB&R console and that requires 64-bit OS in its turn. Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Retain Restore Points

Veeam Logoby ePowerIT » Tue Jul 11, 2017 8:36 pm

Hi Guys,

I am missing something obvious,

I am trying to get the number of restore points a job is set to retain. I thought I would find this within the get-vbrjob, or get Get-VBRJobScheduleOptions cmdlets, but can't seem to see them.

Am I being silly?

Thanks

David
ePowerIT
Novice
 
Posts: 4
Liked: never
Joined: Thu Jun 22, 2017 9:09 pm
Full Name: David Dowle

[MERGED] Full / Incremental

Veeam Logoby ePowerIT » Tue Jul 11, 2017 8:36 pm

Guys,

Is there a way to find out from Get-VBRJobScheduleOptions (or other cmdlet) when full and incremental backups are set for?

Thanks

David
ePowerIT
Novice
 
Posts: 4
Liked: never
Joined: Thu Jun 22, 2017 9:09 pm
Full Name: David Dowle

Re: Get Backup Job Schedule and Repository

Veeam Logoby v.Eremin » Wed Jul 12, 2017 1:03 pm

Hi, David,

Kindly, check the examples above and ask for additional help, if needed.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] List jobs by start time

Veeam Logoby marius roma » Wed Jul 12, 2017 1:13 pm

I need to extract a list of replica jobs and, for each job, I need to list the scheduling information, i.e. job1 is scheduled to start every monday at 22:00, job 2 is scheduled to start every day at 22:30, and so on.
Is there any sample I can start from?
Regards
marius
marius roma
Expert
 
Posts: 317
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests