11-15-2021 06:48 AM
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!
Solved! Go to Solution.
11-18-2021 08:39 AM
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.
11-23-2021 06:29 AM - edited 11-23-2021 06:30 AM
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.
11-29-2021 09:51 AM
@JimmyB2 Glad I could help you with a starting point. If you have any questions don't hesitate to reach out.
11-15-2021 08:38 AM
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/
11-18-2021 06:42 AM - edited 11-18-2021 07:34 AM
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"
11-18-2021 06:51 AM
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.
11-18-2021 08:39 AM
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.
11-23-2021 06:29 AM - edited 11-23-2021 06:30 AM
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.
11-29-2021 09:51 AM
@JimmyB2 Glad I could help you with a starting point. If you have any questions don't hesitate to reach out.
11-30-2021 02:21 AM
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.