bseltz-cohesity / scripts

Cohesity REST API examples in PowerShell and Python
Apache License 2.0
102 stars 40 forks source link

restorereport.ps1 does not display all restores ? #143

Closed pge92 closed 8 months ago

pge92 commented 8 months ago

hi, thank you for your hard work on cohesity api & scripts :)

i've got a problem with the restorereport pwsh script. it does not show most of restores that occurred in January + gives wrong infrormation when saying 0 restore tasks : i think it does not show the last SQL restores (but is able to show oldest SQL restores from December when i put more days )

./restoreReport.ps1 -vip yyyy-username readerapi -lastXDays 10
Connected!
Retrieved 0 restore tasks...
Saving output to restoreReport-2024-01-26.html and restoreReport-2024-01-26.csv

cat restoreReport-yyyy-2024-01-26.csv
Date,Task,Object,Type,Target,Status,Duration (Min),Restore Point,User
01/18/2024 14:48:31,Recover_VM_Jan_18_2024_2_45_PM,xxx,VMware,copy-xxx,Success,5,01/18/2024 11:56:12,admin
01/18/2024 14:37:46,Clone-VMs_Jan_18_2024_2-35pm,xxx,VMware,copy-xxx0120240118,Failure,2,01/18/2024 11:56:12,admin
01/18/2024 14:19:39,Clone-VMs_Jan_18_2024_2-13pm,xxx,VMware,xxx_1801202,Failure,2,01/18/2024 11:56:12,admin

==> when performing the API call with the same parameters it seems to show the SQL restores as you can see :

_performRestoreTaskState
-----------------------
@{base=; fullViewName=cohesity_int_1620747_2b01; viewBoxId=44585; restoredDataStorageDomainId=44585; progressMonitorTaskPath=recover_1620747; objects=System.Object[]; restoredToDifferentSource=True; restore…
@{base=; fullViewName=new; viewBoxId=44585; restoredDataStorageDomainId=44585; progressMonitorTaskPath=clone_1620740; objects=System.Object[]; restoredToDifferentSource=True; restoreParentSource=; isMultiSt…
@{base=; fullViewName=new; viewBoxId=44585; restoredDataStorageDomainId=44585; progressMonitorTaskPath=clone_1619767; objects=System.Object[]; restoredToDifferentSource=True; restoreParentSource=; isMultiSt…
@{base=; restoreSubTaskVec=System.Object[]; restoreAppTaskState=; restoreInfo=}
@{base=; restoreSubTaskVec=System.Object[]; restoreAppTaskState=; restoreInfo=}
@{base=; restoreSubTaskVec=System.Object[]; restoreAppTaskState=; restoreInfo=}
.....
@{base=; restoreSubTaskVec=System.Object[]; restoreAppTaskState=; restoreInfo=}
@{base=; restoreSubTaskVec=System.Object[]; restoreAppTaskState=; restoreInfo=}
@{base=; restoreSubTaskVec=System.Object[]; restoreAppTaskState=; restoreInfo=}_

and i'm able to find the lines using data-protect/recoveries... weird could you please help ?

bseltz-cohesity commented 8 months ago

I see, the script needs to be updated to support the cart-based restores introduced in 6.8.1. I will work on it.

bseltz-cohesity commented 8 months ago

Updated, let me know how it works for you: https://github.com/bseltz-cohesity/scripts/tree/master/reports/powershell/restoreReport

pge92 commented 8 months ago

great job, it works now 👍

by the way you have to change the output name displayed at the end of the script which does not contain the Cluster name : ===> "Saving output to restoreReport-$now.html and restoreReport-$now.csv" Should be restoreReport-$($cluster.name)-$($now) for both, as the created report names contain CLuster.name

thank you for your help and support

pge92 commented 8 months ago

oh sorry, it seems that the TYPE is not correctly set up, as the SQL restore are entered either empty or as 'VMWare' as you can see : _Date,Task,Object,Type,Target,Status,Duration (Min),Restore Point,User 01/25/2024 15:53:28,Recover_MS_SQL_xxxxxxxxxx_2024-01-25_15:53:28_1,xxxxxxx,,yyyyxxxxx,Success,356,01/24/2024 20:30:01,power_api 01/18/2024 11:49:37,Recover_MS_SQL_xxxxxxxxxx_2024-01-18_11:49:37_1,xxxxxxx,VMware,yyyyyyzzzz,Success,730,01/17/2024 20:30:01,powerapi

bseltz-cohesity commented 8 months ago

Ah, I see. Fixed!

pge92 commented 8 months ago

tested, it is ok. thx a lot