$jobs = api get protectionJobs
$jobs | ft
id name environment policyId viewBoxId parentSourceId sourceIds
-- ---- ----------- -------- --------- -------------- ---------
7 VM Backup kVMware 770535285385794:1544976774290:5 5 1 {1757, 29, 30}
12 Infrastructure kVMware 770535285385794:1544976774290:5 5 1 {121, 2246, 2247, 3...
35 Oracle Adapter kOracle 770535285385794:1544976774290:377 5 64 {61}
6222 File-Based Backup kPhysicalFiles 770535285385794:1544976774290:134306 5 60 {98}
8028 SQL Backup kSQL 770535285385794:1544976774290:377 5 46 {31}
31495 Generic NAS kGenericNas 770535285385794:1544976774290:25 5 85 {1759}
32392 CentOS3 kPhysical 770535285385794:1544976774290:25 5 60 {98}
32793 Scripts Backup kView 770535285385794:1544976774290:134306 5 102 {116}
35465 RMAN Backup kPuppeteer 770535285385794:1544976774290:25 5 102 {1741}
51831 NetAppJob kNetapp 770535285385794:1544976774290:25 5 1760 {1761}
115092 Utils Backup kView 770535285385794:1544976774290:25 5 102 {1783}
147898 PhysWin kPhysicalFiles 770535285385794:1544976774290:25 5 60 {67}
148108 _DELETED_autotest kVMware 770535285385794:1544976774290:25 5 1 {3}
148441 OraFile kPhysicalFiles 770535285385794:1544976774290:25 5 60 {1738}
$jobs[0]
id : 7
name : VM Backup
environment : kVMware
policyId : 770535285385794:1544976774290:5
viewBoxId : 5
parentSourceId : 1
sourceIds : {1757, 29, 30}
startTime : @{hour=23; minute=25}
timezone : America/New_York
incrementalProtectionSlaTimeMins : 60
fullProtectionSlaTimeMins : 120
priority : kMedium
alertingPolicy : {kFailure}
indexingPolicy : @{disableIndexing=False; allowPrefixes=System.Object[]; denyPrefixes=System.Object[]}
qosType : kBackupHDD
environmentParameters : @{vmwareParameters=}
uid : @{id=7; clusterId=770535285385794; clusterIncarnationId=1544976774290}
policyAppliedTimeMsecs : 1564567626395
modificationTimeUsecs : 1564567626395979
modifiedByUser : admin
creationTimeUsecs : 1544977491464965
isPaused : False
Now let's say we want to change the start time of the job to 11PM. First we can make the changes to the job object we just retrieved:
$jobs[0].startTime.hour = 23
$jobs[0].startTime.minute = 00
then we can put the job back to save it back to Cohesity:
api put "protectionJobs/$($jobs[0].id)" $jobs[0]
Notice the use of the put verb. This verb is used when updating an existing object.
Next, let's add a VM called CentOS5 to our protection job. First we need to find the ID of the VM, then add it to the list of source IDs in the job:
$vm = api get protectionSources/virtualMachines | Where-Object { $_.name -eq 'CentOS5' }
$vm
id : 2252
parentId : 1
name : CentOS5
environment : kVMware
vmWareProtectionSource : @{type=kVirtualMachine; name=CentOS5; id=; connectionState=kConnected;
toolsRunningStatus=kGuestToolsRunning; virtualDisks=System.Object[]}
$vm.id
2252
$jobs[0].sourceIds += $vm.id
api put "protectionJobs/$($jobs[0].id)" $jobs[0]
Easily done. Now, what if you want to create a brand new job? Well, that can be more challenging, but if you know where to look, you can see everything that is going on behind the scenes in the Cohesity UI. That will be the topic of my next post...