Skip to main content

Hello everyone,

 

Is it possible to get Full Schedules via API call? i am able to get the schedules and sub tasks inside the schedule but i could not find a way to differentiate schedules from Full, vs Incremental vs Full Synthetic?  

Granted Full Synthetic has a display name so it lets you differentiate from Full and incremental but Full backup and incremental does not have any name in schedules.is there any other property that i can key off? 

 

 

 

 

 

 

Thank you! 

 

 

 

I think that the property you are looking for is backupLevel. I can see it on the Return of RestAPI for the schedules call

https://api.commvault.com/#db660d18-2c7c-48a5-904a-c250bd105104

 

that is also confirmed in the qoperations page:

https://documentation.commvault.com/2022e/essential/48814_rest_api_post_schedule_policy.html


Deferring to alt account @christopherlecky 

 


Disclaimer: I am guessing here

 

I have to test this, but if this is any way analogous to the way schedules are returned in the database…

Then I think what he actually wants is http://WebConsoleHostName/webconsole/api/Schedules

With no parameters. Postman and the API documentation by default shows this with parameters but that is just to be specific, without parameters it should return all schedules and schedule policies. 

This is necessary since you can either define a task, or a task with subtasks

This will return all schedules for every entity type, and he would want to filter on “ScheduleType” 

To differentiate between Policies and Standalone tasks.

 

He can then select object to return tasks of specific type, as a schedule policy would not tell you whether a backup is full, synthetic etc.

 

This is a little confusing because api/schedulepolicy would just return the taskid that returns the parent task.

 

So summing up api/schedule returns all tasks including tasks that are supertasks(schedule policies) and standard tasks which is just an individual schedule which may or may not be associated with a schedule policy. 

I’ll confirm this when I get in front of a computer.

 

In the world of powershell, api/schedulepolicy is equivalent to api/schedule | Select-Object $_.tasktype “SchedulePolicy”

 

So you will have more control by doing your own filtering, you will also get a better understanding of the thinking behind scheduling.


thank you! Appreciate it. I will start poking on it as well! 


You’re welcome, your best bet is to pull in the schedule with no parameters and view the result in the vscode debugger, then you can see what you need to filter on.


So I got around to taking a look and this is what it looks like. 

When you return the schedule api with no parameters you get this Json Structure

 

“Taskdetail” is an array of schedules and “tasktype” when returned from this api is an integer.

This matches what is returned when you query the DB, I am pretty sure the tasktype for a schedule policy is 4.

 

I didn’t have time to dig further, but you will see that literally all schedules are returned so now your primary issue is filtering. 

 


Hello ,

 

I am not an expert with PowerShell or API but I did manage to find this info.

I am sure this can be optimized further. 

 

I used these commands post login call. - > called schedule policy to determine id, used to get response1.

called response1 subtasks options to find backup level. the policy I am using only has a synth full and an incremental which is displayed as value 2 and 4 .

$response = Invoke-RestMethod 'http://commserve.cv.lab/webconsole/api/SchedulePolicy' -Method 'GET' -Headers $headers


$response1 = Invoke-RestMethod 'http://commserve.cv.lab/webconsole/api/SchedulePolicy/51' -Method 'GET' -Headers $headers




$response1.taskinfo.subTasks.options.backupopts | format-list

$response1.taskinfo.subTasks.options.backupopts.backuplevel

 

 


Thank you @christopherlecky, @Damian Andre  and @Mitchell  

This helped a lot!  here is sample script to update incremental schedule

 

	#$planname = "z_SF3_test"
$response = Invoke-RestMethod 'http://my-commserve-fqdn/webconsole/api/Plan' -Method 'GET' -Headers $headers
$planCheck = $response.plans.plan | where planName -eq "$plan"

if ($planCheck -ne $null) {

$CurrentPlanID = $planCheck | select -ExpandProperty PlanID
$response = Invoke-RestMethod "http://my-commserve-fqdn/webconsole/api/Plan/$CurrentPlanID" -Method 'GET' -Headers $headers
$planpolicyID = $response.plan.schedule.task | select -ExpandProperty taskID
$response = Invoke-RestMethod "http://my-commserve-fqdn/webconsole/api/SchedulePolicy/$planpolicyID" -Method 'GET' -Headers $headers

#Incremental schedule same as scheduleID
$planscheduleID = $response.taskInfo.subTasks | where {$_.options.backupopts.backuplevel -eq 2} | select -ExpandProperty SubTask | select -ExpandProperty SubTaskID

#Get timezone
$timezone = $response.taskInfo.subTasks | where {$_.options.backupopts.backuplevel -eq 2} | select -ExpandProperty pattern | select -ExpandProperty timezone | select -ExpandProperty TimeZoneID

#Get Starttime
$starttime = $response.taskInfo.subTasks | where {$_.options.backupopts.backuplevel -eq 2} | select -ExpandProperty pattern | select -ExpandProperty active_start_time

#Form JSON file lSystem.Collections.ArrayList]$IncrementalDays="SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"
$tid = @()
$tid = iPSCustomObject]@{
id = $timeZone
}
$schedulePattern_Incr = @()
$schedulePattern_Incr = cPSCustomObject]@{
scheduleFrequencyType = "WEEKLY";
startTime = $startTime;
frequency = 1;
weeklyDays = @($IncrementalDays);
timezone = $tid
}
$schedules = @()
$schedules += sPSCustomObject]@{
backupType = "INCREMENTAL";
scheduleOperation = "MODIFY";
schedulePattern = $schedulePattern_Incr;
forDatabasesOnly = $false;
scheduleId = $planscheduleID;
policyId = $planpolicyID
}
$backupFrequency = @()
$backupFrequency = cPSCustomObject]@{
schedules = $schedules
}
$JSON_Raw = @()
$JSON_Raw = aPSCustomObject]@{
backupFrequency = $backupFrequency
}
$body = $JSON_Raw | ConvertTo-Json -Depth 10
#Ignore SSL Error
/System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
#Post Schedule Updates
$response = Invoke-RestMethod "https://my-commserve-fqdn/commandcenter/api/V4/ServerPlan/$CurrentPlanID/RPO" -Method 'PUT' -Headers $headers -Body $body
$response
sleep 5
} else {
Write-Host "Plan $plan does not exist"
}

 

 


Reply