cancel
Showing results for 
Search instead for 
Did you mean: 

API call to show backup jobs within the last 7 days

JimmyB2
Level 4

Hi all,

I want to build an API call that shows backup jobs from the last 7 days. What I do not know, is how to write the filter part of the script. The documentation says

startTime     eq ne lt gt le ge     The time when the job started.    date-time

What format should the 'date-time' have? Is it possible to somehow define last 7 days?

Any help much appriciated!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Krutons
Level 6
   VIP   

This file should have an updated pagination method that will let you go through all of the results in your API call based on filters. Same thing, save it as a .ps1 and try it out.

Let me know if you have any questions.

View solution in original post

7 REPLIES 7

Nicolai
Moderator
Moderator
Partner    VIP   

Hi @JimmyB2 

I found this example : https://sort.veritas.com/public/documents/nbu/9.1/windowsandunix/productguides/html/getting-started/

And the JSON response look like this: 

  "startTime": "2018-01-09T10:03:22.000Z",
            "endTime": "2018-01-09T10:03:23.000Z",
            "activeTryStartTime": "2018-01-09T10:03:22.000Z",
            "lastUpdateTime": "2018-01-09T10:03:23.256Z",

 So I would presume the JSON request format would be in the same time/date format (I reserve every right to be wrong).

The different REST call for different versions of Netbackup can be found here: 

https://sort.veritas.com/public/documents/nbu/9.1/windowsandunix/productguides/html/getting-started/

Krutons
Level 6
   VIP   

Hey Jimmy, sorry I've been busy with work. You will also want to be able to utilize pagination so that you can return all of the results inside our API call and not just the default maximum 100. Here is an example to return ALL backup jobs, you could filter it though. Attached is an example on how to handle pagination.

Edit: I think I actually need to look at the pagination for this API call, looks like something might have changed in 9.1 and the way I had pagination setup isn't working, I'll run some tests.

 

You can save it as a .ps1 and test it. If you only the want the previous 7 days you could add something like the following

 

 

 

$currentDate = Get-Date
$currentDate = $currentDate.ToString('yyyy-MM-dd')

 

 

 

 

This should work.

 

$date = (Get-Date).AddDays(-7)
$date = $date.ToString('MM-dd-yyyyThh:mm:ss.000Z')

filter="startTime gt $date"

 

 

Krutons
Level 6
   VIP   

One way to see what you are able to return/schema is when you get our API return

$content = (ConvertFrom-Json -InputObject $response)

write-output $content.data

Then try write-output $content.data.attributes

I'd suggest looking for the schema as well as playing around like this to understand how things work.

Krutons
Level 6
   VIP   

This file should have an updated pagination method that will let you go through all of the results in your API call based on filters. Same thing, save it as a .ps1 and try it out.

Let me know if you have any questions.

View solution in original post

JimmyB2
Level 4

Hi @Krutons  Krutons !

Thank you so much for your support. Words cannot express how much you have helped me so far!

I can confirm that your script works well. I have used the part of the script and added it to the one script, that displays services and processes on the master server and jobs and alerts from the whole netbackup environment. The uuid ($uuid_master) of the master server is there hardcoded. I think, it is just nice script to have basic monitoring data in one output.

 

Krutons
Level 6
   VIP   

@JimmyB2 Glad I could help you with a starting point. If you have any questions don't hesitate to reach out.

JimmyB2
Level 4

Hi Krutons, once a gain, thank you so much for your support. If any other questions, I will reach out the forum. I will close this threat.