search for snapshots sorted by creation date
-
Hi everyone, I am looking for a way to find snapshots in my pool that are pretty old so I can remove them. finding the "type" snapshot is not complicated but seeing the creation date and sorting them by that is my actual problem, is there a way for that?
cheers Ringo -
I haven't seen a way to do this from within XO. However, you can gather the details using
xe
on the command line --for i in `xe snapshot-list | grep uuid | awk '{print$5}'`; do export j=$(xe snapshot-param-get uuid=$i param-name=children); k=$(xe snapshot-param-get uuid=$i param-name=snapshot-time); echo "VM UUID: $j - Snapshot UUID: $i - Creation Time: $k"; done
This doesn't sort the results, so you will need to do that in Excel or your favorite text editor.
-
I think that should be doable with our REST API or at worst our existing API. Pinging @julien-f
-
@olivierlambert We are interested in that too. Any news?
It would be a wonderful integration to our icinga check for snapshots.
-
I think it's now possible since last release. Let me ping @julien-f
-
@olivierlambert Thank you.
-
Hello,
Yes, the list of VM snapshots in now exposed by the REST API, the path is
/rest/v0/vm-snapshots
.The list of available collections is under the path
/rest/v0
.More info in the documentation: https://xen-orchestra.com/docs/restapi.html
-
@julien-f thank you.
Is it possible to filter by creation date? -
@Steve_Sibilia Yes.
- Take a look at a specific snapshot to see the available fields, note
snapshot_time
which is a Unix timestamp. - Use a filter (syntax documentation), example:
/rest/v0/vm-snapshots?filter=snapshot_time%3A>1669044124
- Take a look at a specific snapshot to see the available fields, note
-
@Steve_Sibilia hey, what icinga check are you using for snapshots? do you have any xcp-ng related icinga checks running?
-
@vmpr Hi, i wrote my own to find any vm with more than X snapshot which has an age of Y days.
If you are interested I can share it, I need a little bit of time to translate comments and help in english.
For xcp-ng i wrote onther check to get the size of hba storage SR's.
-
Any helper and use case is welcome, feel free to link to your Github or Gitlab repository!
-
@olivierlambert here it is: https://github.com/Stevesibilia/check_snapshot
Keep in mind i'm not a developer