How to get the snapshot id of the last on-demand backup

Using the below API I will get the list of all the snapshots but how will I get the snapshot id of the latest on-demand backup from that list?

curl -X GET -i --digest -u “{PUBLIC-KEY}:{PRIVATE-KEY}” “

Hi @Vikas_Rathore,

When you create the snapshot, you send a description which is returned when you list the snapshots.

Would that work if you choose a specific pattern and then filter on it?


@MaBeuLux88 Thanks for helping.

Could you provide an example of how I can add a filter? Also, I might have multiple snapshots with the same description. can’t we do sorting according to the date it got created?

CODE=curl --user "${{ secrets.PUBLIC_KEY }}:${{ secrets.PRIVATE_KEY }}" \ --digest --include \ --header "Accept: application/json" \ --header "Content-Type: application/json" \ --request POST "${{ secrets.PROJECT_ID }}/clusters/cluster-1/backup/snapshots?pretty=true" \ --data '{ "description" : "On Demand Snapshot", "retentionInDays" : 3 }'

Yes the date is provided. See the field

You will have to implement the filter and the sort in your back-end code once the results are collected.

Supporting these options would make the API way more complex to support filtering and sorting on all the fields.

@MaBeuLux88 I am not using this in the backend code but I want to trigger it from a bash script in our CI/CD pipeline

Well it’s not the easiest language to process JSON but I think it’s doable. With some grep, sort, cut and a few other magic commands I guess you can achieve this without too much trouble.